Android Question b4xCanvas MeasureText (Multiline)

fbritop

Active Member
Licensed User
Longtime User
Is it posible to calculate the height of a label and text, but with multiple lines? The way that b4i SizeToFit works I think.

Thanks
FBP
 

roumei

Active Member
Licensed User
Have you tried StringUtils.MeasureMultilineTextHeight?
Drawing Multiline Text | B4X Programming Forum

This is my code to fit the textsize of a label:
B4X:
Private Sub FontToFitMultiLine(lbl As Label, MaxSize As Float)
    lbl.TextSize = MaxSize
    Do While su.MeasureMultilineTextHeight(lbl, lbl.Text) > lbl.Height
        lbl.TextSize = lbl.TextSize * 0.9
    Loop
End Sub
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
this is what you want.

1611737555840.png
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
I use this in my projects.
 
Upvote 0

fbritop

Active Member
Licensed User
Longtime User
Have you tried StringUtils.MeasureMultilineTextHeight?
Drawing Multiline Text | B4X Programming Forum

This is my code to fit the textsize of a label:
B4X:
Private Sub FontToFitMultiLine(lbl As Label, MaxSize As Float)
    lbl.TextSize = MaxSize
    Do While su.MeasureMultilineTextHeight(lbl, lbl.Text) > lbl.Height
        lbl.TextSize = lbl.TextSize * 0.9
    Loop
End Sub
Yes but what I need is to adjust the label size to fit the font, not to change the font to fit the label size... is all the way arround :(
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User



Search:
 
Upvote 0
Top