Issue
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:
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
Solution
Officially fixed in Support Library rev.22 (Fri March 13, 2015). See relevant google code issue:
https://issuetracker.google.com/issues/37008632
Usage example
theme.xml:
<item name="colorButtonNormal">@color/button_color</item>
v21/theme.xml
<item name="android:colorButtonNormal">@color/button_color</item>
Answered By - WindRider
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.