Android Question Button back color

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
Hi,

Is there a way to get button's color (background & textcolor) in runtime?

(The button is a simple B4A button - dim b as button)

Thanks
 
Solution
hi
i need to GET the color not to SET it
so your solution did not do it...
Just reverse the code.

1674033134119.png


B4X:
Dim ButtonColor As Int = b.As(B4XView).Color
Log(ButtonColor)

klaus

Expert
Licensed User
Longtime User
Declare it as a B4XView then you can set the color with:
Button1.Color = Colors.White
or, if you want a border and corner radii.
Button1.SetColorAndBorder(Colors.White, 1dip, Colors.Black, 10dip)

And to get the color with:
BackColor = Button1.Color
 
Upvote 0

vatedome04

New Member
Declare it as a B4XView then you can set the color with:
Button1.Color = Colors.White
or, if you want a border and corner radii.
Button1.SetColorAndBorder(Colors.White, 1dip, Colors.Black, 10dip)

And to get the color with:
BackColor = Button1.Color
thank you for sharing i got same problem
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
Declare it as a B4XView then you can set the color with:
Button1.Color = Colors.White
or, if you want a border and corner radii.
Button1.SetColorAndBorder(Colors.White, 1dip, Colors.Black, 10dip)

And to get the color with:
BackColor = Button1.Color
Thanks,

As said it's a simple button (old app) so I can't go now and change it all...
So your solution as good as it is is not applicable for my app

So, is there a way to get the colors of a simple button that was declared dim b as button?

Thanks
 
Upvote 0
Top