S stevetheframe Member Licensed User Longtime User Apr 11, 2020 #1 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: Copy 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))
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: Copy 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))
Erel B4X founder Staff member Licensed User Longtime User Apr 12, 2020 #2 Another option is to put the label inside a pane(l). Upvote 1