I searched this ad nauseam and maybe I'll get a solution once and for all:
A label of a known and fixed height needs to have a "maximum" textsize - that is the text should fill the entire height of the label, well almost entirely.
I use a loop to determine the maximum textsize:
The problem is that the top lead space takes "a lot of" space. GRAVITY.TOP does not help.
I even tried "reducing" the padding with:
but it didn't help.
I usually solve this by drawing the text on the label with canvs.Drawtext, thus eliminating the top-lead problem
but I would like to know if there's any way to do that without drawing the text.
A label of a known and fixed height needs to have a "maximum" textsize - that is the text should fill the entire height of the label, well almost entirely.
I use a loop to determine the maximum textsize:
B4X:
canvs.Initialize(lbl)
f=lbl.TextSize
h=canvs.MeasureStringHeight(lbl.Text,lbl.Typeface,f)
Do While h<lbl.Height
f=f+1
h=canvs.MeasureStringHeight(lbl.Text,lbl.Typeface,f)
Loop
f=f-1
lbl.TextSize=f
The problem is that the top lead space takes "a lot of" space. GRAVITY.TOP does not help.
I even tried "reducing" the padding with:
B4X:
Dim r As Reflector
r.Target = lbl
r.RunMethod4("setPadding", Array As Object(0, 1dip, 0, 0), Array As String("java.lang.int", "java.lang.int", "java.lang.int", "java.lang.int"))
I usually solve this by drawing the text on the label with canvs.Drawtext, thus eliminating the top-lead problem
but I would like to know if there's any way to do that without drawing the text.