0

Possible Duplicate:
Standard Android Button with a different color

I have 1 problem - I need to change a color for standard button. I do it using "background" property of button. But when I do it button will change it's shape - rounded corners will disappear, button won't change a color by click (hightlight), color of button won't be gradient. How can I fix this problems? I want to change button's color it to look like a standard button.

Community
  • 1
  • 1
user1078760
  • 749
  • 2
  • 11
  • 17

1 Answers1

2

You have two options - one is using statelist drawable for background and setting drawables for normal, pressed and focused button, and other is using color filter, which will change color without changing basic appearance:

Button button = ...;
button.getBackground().setColorFilter(0xFFff0000, PorterDuff.Mode.MULTIPLY); //red for example
Vladimir
  • 9,683
  • 6
  • 36
  • 57