Hi.
Is there a better way to acomplish this?
I need to paint a label, based on the value, from light red to solid green, passing through the yellow.
My solution:
Could be a range like this:
Is there a better way to acomplish this?
I need to paint a label, based on the value, from light red to solid green, passing through the yellow.
My solution:
B4X:
' Use: myLabel.Style = Paint(mylabel.text)
Sub Paint(value As Double) As String
Dim rgb As String
If value > 90 Then rgb = "0,128,0"
If value > 80 And value < 91 Then rgb = "0,255,0"
If value > 60 And value < 81 Then rgb = "128,255,0"
If value > 40 And value < 61 Then rgb = "255,255,0"
If value > 20 And value < 41 Then rgb = "255,255,128"
If value > 10 And value < 21 Then rgb = "255,128,128"
If value < 11 Then rgb = "255,0,0"
Return $"-fx-Font-size: 18px; -fx-Font-weight: bold; -fx-background-color: rgb(${rgb});"$
End Sub
Could be a range like this:
Last edited: