B4J Question Change style of specific button

Mostez

Well-Known Member
Licensed User
Longtime User
I want to style a specific button differently from the others in style file, to draw the user's attention before they click it. For example, to change the text color, background color, or hover color to red. how to do that?

TIA
 

Daestrum

Expert
Licensed User
Longtime User
Set the controls ID then you can select it directly in a css file with #YourControlsID.

B4X:
    Button1.As(JavaObject).RunMethod("setId",Array("Button1"))
    MainForm.Stylesheets.Add(File.GetUri(File.DirAssets, "mycss.css"))

' css file mycss.css
#Button1:hover{
    -fx-background-color: red;
    -fx-background-insets: 0 0 -1 0, 0, 1, 2;
    -fx-background-radius: 3px, 3px, 2px, 1px;
    -fx-padding: 0.333333em 0.666667em 0.333333em 0.666667em; /* 4 8 4 8 */
    -fx-text-fill: -fx-text-base-color;
    -fx-alignment: CENTER;
    -fx-content-display: LEFT;
}
 
Upvote 0
Top