2

Possible Duplicate:
Standard Android Button with a different color

i would like to make a red button in my android application.

i need it to be red from the start and i also need it to stay red after events.

is there a way of doing this?

Community
  • 1
  • 1
user661135
  • 93
  • 1
  • 2
  • 8

1 Answers1

11

Did you try at all to get some info about this? ;)

http://developer.android.com/reference/android/widget/Button.html Read that to know how to declare buttons

I use this personally (implying a Button has already been declared as button, as above):

button.getBackground().setColorFilter(0xFFFF0000,PorterDuff.Mode.MULTIPLY);

This ensures that it looks like a Button after you apply the new color too. I had issues with setBackgroundColor(int color) on that note.

You can also use Color.RED instead of the Hex value that I put.

Codemonkey
  • 3,412
  • 3
  • 20
  • 24