Hi, with labels I do it with the following code and it works very well.
Now I need to do the same for some buttons.
How can I do it?
Thank you.
Now I need to do the same for some buttons.
How can I do it?
Thank you.
B4X:
Sub SetLabelTextSize(lbl As Label, txt As String, MaxFontSize As Float, MinFontSize As Float) As ResumableSub
Dim FontSize = MaxFontSize As Float
Dim Height As Int
Dim stu As StringUtils
'
lbl.TextSize = FontSize
Height = stu.MeasureMultilineTextHeight(lbl, txt)
Do While Height > lbl.Height And FontSize > MinFontSize
FontSize = FontSize - 1
lbl.TextSize = FontSize
Height = stu.MeasureMultilineTextHeight(lbl, txt)
Loop
'
Return FontSize
End Sub