B4J Question Set gradient colors using CSSUtils

crt

Member
Licensed User
Longtime User
Hello again,
I'm trying to have in my app where an end user can select different colors of a gradient fill. I'm trying to use CSSUtils.SetStyleProperty but I can't seem to get the proper syntax.
I can do it with:
B4X:
Pane1.Style = "-fx-background-color: linear-gradient(#2211FE, #ff33DE);"
but then it wipes out my corner radius.
I've tried:
B4X:
CSSUtils.SetStyleProperty(Pane1,"-fx-background-color: linear-gradient", (#2211FF, #ff33DE))
But I get an "error parsing attribute"
Any suggestions would be grateful.
 
Last edited:

Daestrum

Well-Known Member
Licensed User
Longtime User
B4X:
CSSUtils.SetStyleProperty(Panel1,"-fx-background-color","linear-gradient(#2211FF, #ff33DE)")
 
Upvote 0

crt

Member
Licensed User
Longtime User
It's not an answer but an hint for anybody, who is optimizing his work with css, i found http://www.colorzilla.com/gradient-editor/
Here you can interactive try out your colours, designs etc.
That is great news, comes in handy. Thanks

Just another tidbit for anyone that wants to use variables from colorpicker to set gradient colors.
B4X:
Dim GColor1 As Paint
Dim GColor2 As Paint
GColor1 = ColorPicker1.SelectedColor
GColor2 = ColorPicker2.SelectedColor

CSSUtils.SetStyleProperty(Pane1,"-fx-background-color","linear-gradient(" & CSSUtils.ColorToHex(GColor1) & "," & CSSUtils.ColorToHex(GColor2) & ")")
 
Upvote 0
Top