In stringutils, we have the MeasureMultilineTextHeight feature to help determine the proper height of a label with multiple lines of text. I would like a similar feature to get the width of a text string, so as to set the width of a label dynamically based on the length of the text assigned to it. Any ideas on getting some kind of "text width" ??
To experiment with this, I put in the following code in a button click event:
B4X:
Dim C As Canvas
Dim X As Int
X=C.MeasureStringWidth("textwidth",default_font,30)
Msgbox(x,"")
I received a Null Pointer Exception error when I ran it. BTW, value of default_font is assigned in activity_create, and functions as desired throughout the app.