Coloring Buttons in Android with Material Design and AppCompat

Before the AppCompat update came out today I was able to change the color of buttons in Android L but not on older versions. After including the new AppCompat update I am unable to change the color for either version, when I do try the button just disappears. Does anyone know how to change the button color?

The following pictures shows what I want to achieve:

picture showing desired result

The white button is default, the red one is what I want.

This is what I was doing previously to change the color of the buttons in the styles.xml:

<item name="android:colorButtonNormal">insert color here</item>

and to do it dynamically:

button.getBackground().setColorFilter(getResources().getColor(insert color here), PorterDuff.Mode.MULTIPLY);

Also I did change the theme parent from @android:style/Theme.Material.Light.DarkActionBar to Theme.AppCompat.Light.DarkActionBar

28 Answers
28

Leave a Comment