I have a label that changes dimension in realtime, like this: factor = 1.1 label1.Height = Round(factor * label1.Height) label1.Width = Round(factor * label1.Width) label1.TextSize = ?? How can I scale TextSize?
I have a label with text "Address Line 1" at font size 20. I need to know the minimum width that will accommodate this text on a single line so I can set the smaller labels to be the same width so everything lines up.
I've worked out a way, it's a bit messy but it works.
I added a hidden label (lblHidden) in the designer with the same font definition as the label I want to get the minimum width for.
B4X:
Dim su As StringUtils
Dim startHeight As Int = su.MeasureMultilineTextHeight(lblHidden,"A")
Dim thisHeight As Int = 100%y
Dim thisWidth As Int = 0
Do Until thisHeight = startHeight
thisWidth = thisWidth + 1
lblHidden.Width = thisWidth
thisHeight = su.MeasureMultilineTextHeight(lblHidden,"Address Line 1")
Loop
After the loop, thisWidth is the minimum width a label must be to fit "Address Line 1" without text wrapping.
If anyone knows of a better way (ideally built in) then please let me know.