Other Label background color, gotcha

stevetheframe

Member
Licensed User
Longtime User
I wanted to change the background color of a label using CSSUtils.SetBackgroundColor, and I wondered why it wasn't working.
Turned out that the background color only changes when there is text in the label and only for the extent of the text.
So, if you need to start off with just a colored background you'll need to put some dummy text colored the same as the background.

B4X:
        lbl4.Text = "MOUNTCOLOURMOUNTCOLOUR"    'background only works for the extent of the text
        lbl4.TextColor = fx.colors.RGB(112,88,46)
        CSSUtils.SetBackgroundColor(lbl4, fx.colors.RGB(112,88,46))
 
Top