Font size

omoba

Active Member
Licensed User
Longtime User
Hi,

I created a seekbar to increase and decrease font size.

When I increase the font size and the text gets big enough/too big, the text goes outside the view-able range of the label.

Is there a way to prevent this from happening?

Thanks
 

derez

Expert
Licensed User
Longtime User
You should limit the size set by the seekbar, say to FontLimit:
B4X:
sub sb_ValueChanged (Value As Int, UserChanged As Boolean)
fontsize = min(Value, FontLimit)

Another way is to use canvas methods,
B4X:
MeasureStringWidth (Text As String, Typeface As android.graphics.Typeface, TextSize As Float) As Float
or to measure the Height with MeasureStringHeight
 
Last edited:
Upvote 0
Top