I abandoned a program I have been working on for nearly 2 years because I couldn't solve several problems with it. I Figured what I wanted to do couldn't be accomplished with B4A. I thought I'd give it another try again. I did finally manage to fix one serious bug I had. The other one is related to using a Label in a remote view (widget).
So, if I wanted to do MeasureMultilineTextHeight(Label1, Label1.Text) in a remote view (home screen widget) is there a way to do this? I cannot use Label1.text.
You don't need to use the actual label to measure the string height, you can create a dummy label with the same Font, on a dummy panel. It appears that the panel doesn't need to be added to an activity for it to work try this:
B4X:
Dim P As Panel
P.Initialize("")
Dim L As Label
L.Initialize("")
P.AddView(L,0,0,150,30)
Dim SU As StringUtils
Log(SU.MeasureMultilineTextHeight(L,"Test "& CRLF & "Test2"))
You don't need to use the actual label to measure the string height, you can create a dummy label with the same Font, on a dummy panel. It appears that the panel doesn't need to be added to an activity for it to work try this:
B4X:
Dim P As Panel
P.Initialize("")
Dim L As Label
L.Initialize("")
P.AddView(L,0,0,150,30)
Dim SU As StringUtils
Log(SU.MeasureMultilineTextHeight(L,"Test "& CRLF & "Test2"))
What exactly are you trying to do? The size will be the same in an activity or in a widget. The text in the label can't change unless you change it, so you can know the size when you change it using this code.
Sorry, I didn't give you the entire explanation. The text does change as buttons are pressed. The buttons selects an item from a list and is displayed in the label. The user can edit this list up to a maximum of 20 characters per item. I'm trying to keep the label as small as possible because it's part of a widget. So, the feature I need is to vary the text size to fit the label.
Thank you for your help it is greatly appreciated. I will try this later today at when I get home. Will let you know how it works out.
Thanks again,
Bryan
You are certainly an expert. This looks like it's going to work very nicely. I couldn't figure out how to do this. You deserve a donation for the help. I will arrange it shortly with PayPal.
Thank you very much.
Bryan