Sub getRect(b4xv As B4XView) As B4XRect
Dim b4xc As B4XCanvas
b4xc.Initialize(b4xv)
Return b4xc.MeasureText(b4xv.Text, b4xv.font)
End Sub
If I execute:
B4X:
Dim cls As Label
cls.Initialize("")
cls.SingleLine=True
pInt.AddView(cls, 0,0,1dip,1dip)
b4xV=cls
b4xV.Font=xc.b4xFontBold(xc.bigSize*1.5)
b4xV.Text="Áap"
b4xV.Color=Colors.Yellow
Dim b4xr As B4XRect=xc.getRect(b4xV)
b4xV.SetLayoutAnimated(0, 0,0,b4xr.Width, b4xr.Height)
The outcome is
But if I execute:
B4X:
Dim cls As Label
cls.Initialize("")
cls.SingleLine=True
pInt.AddView(cls, 0,0,1dip,1dip)
b4xV=cls
b4xV.Font=xc.b4xFontBold(xc.bigSize*1.5)
b4xV.Text="a"
b4xV.Color=Colors.Yellow
Dim b4xr As B4XRect=getRect(b4xV)
b4xV.SetLayoutAnimated(0, 0,0,b4xr.Width, b4xr.Height)
The label pads verticaly as it was a string in an uppercase and with accent situation, althow it does not contain that characters
How can I achieve that the text anchors directly to 0x and 0y? with the width there is no problem. The thing comes out with the spacing from the label above the text
The problem is not that the height is not correct, is that there is this padding that I dont know why it forces, you can see the yellow spacing that the label has got on the top, or why if the measure is right, it does not seem to center the text correctly
I have attached a small project which shows the situation.
We cannot use the canvas.DrawText, becuse this labels need to be updated in text and color very frequently.