cancel
Showing results for 
Search instead for 
Did you mean: 

How to set the color of a button from code?

GMeur
Senior

Hello,

Is there a way to change the color of a botton directly from the code?

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Martin KJELDSEN
Chief III

Hi @GMeur​,

There are multiple types of buttons. If you're using a standard Button it requires an image for both released and pressed states so you would have to have assets in the color of your choice.

If you're using a flex button, you might be using a "Box with Border" - And here you can change the color of the box (and thus button) directly.

/Martin

View solution in original post

3 REPLIES 3
Martin KJELDSEN
Chief III

Hi @GMeur​,

There are multiple types of buttons. If you're using a standard Button it requires an image for both released and pressed states so you would have to have assets in the color of your choice.

If you're using a flex button, you might be using a "Box with Border" - And here you can change the color of the box (and thus button) directly.

/Martin

Thanks for your quick reply.

Therefore, if I want to design a keyboard whose color of the keys can be changed easily from the code, I must use flex buttons for them and implement the 'clicklistener' function, right? Can you think of any easier ways of doing it?

That's one way of doing it yeah.