I am relatively new to B4A and am experiencing a problem with labels. Perhaps one of you B4A experts could put me on the right track.
I have distilled the problem to its essentials in the code below.
The first time the button is clicked, the smaller text appears where I would expect - near the top of the label. When the button is re-clicked, the larger text appears in the label, again positioned as I would expect. On the next iteration however, the smaller text appears again, but this time positioned lower, on the baseline of the larger text, I believe.
I can't find any reference on how to control the vertical position of the text.
I have distilled the problem to its essentials in the code below.
The first time the button is clicked, the smaller text appears where I would expect - near the top of the label. When the button is re-clicked, the larger text appears in the label, again positioned as I would expect. On the next iteration however, the smaller text appears again, but this time positioned lower, on the baseline of the larger text, I believe.
I can't find any reference on how to control the vertical position of the text.
B4X:
Sub Process_Globals
End Sub
Sub Globals
Dim lbl As Label
Dim btn As Button
Dim b As Boolean
End Sub
Sub Activity_Create(FirstTime As Boolean)
lbl.Initialize("")
Activity.AddView(lbl,40%x,40%y,20%x,20%y)
lbl.Visible = False
lbl.Color = Colors.Yellow
lbl.TextColor = Colors.Black
lbl.Text = "8"
btn.Initialize("btn")
Activity.AddView(btn,40%x,80%y,20%x,10%y)
btn.Text = "Action"
btn.TextSize = btn.Width/6
End Sub
Sub btn_Click
lbl.Visible = True
b = Not(b)
If b Then ' Smaller Text
lbl.TextSize = lbl.Width / 4
Else ' Larger Text
lbl.TextSize = lbl.Width / 2
End If
End Sub/CODE]
Thanks in advance for any suggestions.
Ron