Android Question Get button color

red30

Well-Known Member
Licensed User
Longtime User
How can I get the color of the button? I can set the color with "btn1.Color = Colors.White", I can’t find out what color the button is now using the condition "If btn1.Color = Colors.White Then" How can I do this?
 

JohnC

Expert
Licensed User
Longtime User
This could be an alternative method if no one else replies with a more direct way:

Store the color in the button's .Tag property.

btn1.color = Colors.White
btn1.Tag = Colors.White

Then...

If btn1.Tag = Colors.White Then
 
Upvote 0

red30

Well-Known Member
Licensed User
Longtime User
Change the button type to B4XView and you will then be able to get the color.

However setting the color like this for a button is usually a mistake. The button will not change its color when it is pressed.
And how can I change the color of the button while maintaining the property that when the button is pressed, it also changes color? For example, I have a green button, when pressed it darkens a little, I change the color to red and now it darkens a little when pressed.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
 
Upvote 0
Top