No matter how hard i try, I cannot get the center-justify to work at all when adding labels by code.
Here is my code block which tries to set the properties of the label:
the code which calls the above code:
Notice, I try to set the justify in 2 different places but no matter what, it just doesn't work. I added a background color to make the issue better stand out:
I tried to log the style property to see if its returning center, and it does. but ONLY when i set it, otherwise it returns empty.
Not sure where to go from here, thoughts?
Here is my code block which tries to set the properties of the label:
B4X:
'Generates a label with all the parameters required for such
Sub AddLabel(labelobject As Label, panelobject As Pane, Params As LabelParams)
labelobject.Initialize("")
labelobject.TextColor = fx.Colors.From32Bit(Params.TextColor)
CSSUtils.SetBackgroundColor(labelobject, fx.Colors.From32Bit(Params.Color))
CSSUtils.SetStyleProperty(labelobject, "-fx-text-alignment", "center")
labelobject.Text = Params.Text
labelobject.WrapText = False
Dim jo As JavaObject = labelobject
jo.RunMethod("setTextAlignment", Array("CENTER"))
labelobject.TextSize = Params.TextSize
Log(CSSUtils.GetStyleProperty(labelobject, "-fx-text-alignment"))
panelobject.AddNode(labelobject, Params.Left, Params.Top, Params.Width, Params.Height)
End Sub
the code which calls the above code:
B4X:
'Draw the Period/Quarter/Inning/Half etc.
Private Sub Draw_period(ArgumentMap As Map)
Dim Property As ControlProperties = ArgumentMap.Get("Property")
Views.lblPeriod.Initialize("")
Dim lParams As LabelParams = Common.CreateLabelParams(Property.Size, Common.StringToInt(Property.TextColor), BackColor, Property.DisplayName, True, Property.Left, Property.Top, Property.Width, Property.Height)
Common.AddLabel(Views.lblPeriod, ScorePanel, lParams)
LoadFont(Views.lblPeriod, Property.FontID)
End Sub
Notice, I try to set the justify in 2 different places but no matter what, it just doesn't work. I added a background color to make the issue better stand out:
I tried to log the style property to see if its returning center, and it does. but ONLY when i set it, otherwise it returns empty.
Not sure where to go from here, thoughts?