B Bryan Member Licensed User Longtime User Dec 8, 2014 #1 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. Thanks, Bryan
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. Thanks, Bryan
stevel05 Expert Licensed User Longtime User Dec 8, 2014 #2 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: Code: Copy 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")) Upvote 0
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: Code: Copy 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"))
B Bryan Member Licensed User Longtime User Dec 8, 2014 #3 stevel05 said: 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: Code: Copy 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")) Click to expand... I think this would work in an Activity but not in a Remoteview (home screen widget) as I need. Am I correct? Upvote 0
stevel05 said: 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: Code: Copy 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")) Click to expand... I think this would work in an Activity but not in a Remoteview (home screen widget) as I need. Am I correct?
stevel05 Expert Licensed User Longtime User Dec 8, 2014 #4 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. Upvote 0
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.
stevel05 Expert Licensed User Longtime User Dec 8, 2014 #5 If you are changing the text and need the Label to change size, set it's height to -2 (fit content) Upvote 0
B Bryan Member Licensed User Longtime User Dec 8, 2014 #6 stevel05 said: If you are changing the text and need the Label to change size, set it's height to -2 (fit content) Click to expand... 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. Bryan Upvote 0
stevel05 said: If you are changing the text and need the Label to change size, set it's height to -2 (fit content) Click to expand... 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. Bryan
stevel05 Expert Licensed User Longtime User Dec 8, 2014 #7 Try this, you'll need to set the dummy label with the same typeface etc that you use for the label on the widget. Attachments WidgetTest.zip WidgetTest.zip 7.6 KB · Views: 379 Upvote 0
Try this, you'll need to set the dummy label with the same typeface etc that you use for the label on the widget.
B Bryan Member Licensed User Longtime User Dec 8, 2014 #8 stevel05 said: Try this, you'll need to set the dummy label with the same typeface etc that you use for the label on the widget. Click to expand... 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 Upvote 0
stevel05 said: Try this, you'll need to set the dummy label with the same typeface etc that you use for the label on the widget. Click to expand... 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
B Bryan Member Licensed User Longtime User Dec 9, 2014 #9 stevel05 said: Try this, you'll need to set the dummy label with the same typeface etc that you use for the label on the widget. Click to expand... 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 Upvote 0
stevel05 said: Try this, you'll need to set the dummy label with the same typeface etc that you use for the label on the widget. Click to expand... 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