B4J Question Label Color From database

Luis Felipe Andrade

Member
Licensed User
Hello,

I have tried to change the color of a TEXT label in B4J, the parameters for the color comes in ARGB with the value 15, 44, 89, 255 (Cain of Blue) but how to combine these numbers with CSSUtils or using label1.style? Please note I can't just type 'Blue' becouse the default Blue is diferent of the color I wish. all the examples on the forum are using the name of the color directly.
Label color:
'Also tryed:
pfontcolor="#FF0F2C59" ' same blue I need
CSSUtils.SetStyleProperty(lbs_dia,"-fx-text-fill",pfontcolor)
'another test:
lbs_dia.Style = "-fx-text-fill: " & pfontcolor & ";"

'But in both cases the color change to blue for the background in the label, but I need to change Textcolor foregroung'

Thank you in advance for your comments.
 

William Lancee

Well-Known Member
Licensed User
Longtime User
The RGBA numbers you mentioned 15, 44, 89, 255 imply that 255 is the transparency (i.e. opaque)
The other number #FF0F2C59 has transparence at the start, which is what is expected in B4X (ARGB).
So there are two convenient ways of setting the TextColor.

B4X:
'method 1
lbs_dia.As(B4XView).TextColor = xui.Color_ARGB(255, 15, 44, 89)

'method 2
lbs_dia.As(B4XView).TextColor = 0xFF0F2C59
 
Upvote 0

Luis Felipe Andrade

Member
Licensed User
The RGBA numbers you mentioned 15, 44, 89, 255 imply that 255 is the transparency (i.e. opaque)
The other number #FF0F2C59 has transparence at the start, which is what is expected in B4X (ARGB).
So there are two convenient ways of setting the TextColor.

B4X:
'method 1
lbs_dia.As(B4XView).TextColor = xui.Color_ARGB(255, 15, 44, 89)

'method 2
lbs_dia.As(B4XView).TextColor = 0xFF0F2C59
Thank you William, this code and example works perfect for me!
 
Upvote 0
Top