When the text doesn't scroll (short than the label width) I wish that the text is horizontally aligned in the center.
To set it I'm using the B4A Designer and for the scrolling label I choose "CENTER_HORIZONTAL" (Horizontal Alignment) but it is displayed as LEFT alignment.
How to solve this ?
Thanks in advance for any suggestion.
The solution you are using provides the entirety of the source code. You need to modify it to do what you need.
Having said that, and briefly looking at the source code, I would start with modifying the setText method to adjust the alignment, something such as:
B4X:
If originalTextWidth <= mBase.Width Then
xlbl.Text = t
xlbl.Gravity = Gravity.Center
p.Tag = "static"
StopScrolling
Else
p.Tag = ""
Dim duplicateText As String = t & " " & t
Dim Width As Float = MeasureTextWidth(duplicateText, fnt)
p.Width = Width
xlbl.Width = Width
xlbl.Text = duplicateText
xlbl.Gravity = Gravity.LEFT
StartScrolling (p, originalTextWidth)
End If
And see if that accomplishes what you're looking for.