Reputation: 6951
I am trying to change the background tint of the default Android Button.
The app:backgroundTint
attribute has bugs, so I don't use it (Pre-Lollipop devices lose their state list)
colorButtonNormal
added to the app theme works, but if I instead add it to a child theme and use the buttonStyle
attribute on the app theme, colorButtonNormal
for some reason gets ignored (all the other child theme attributes are applied).
Is this a bug?
This is my styles.xml:
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="buttonStyle">@style/BlueButton</item>
</style>
<style name="BlueButton" parent="Widget.AppCompat.Button">
<item name="colorButtonNormal">@color/colorPrimary</item> <-- not applied
<item name="android:textColor">#fff</item>
</style>
Upvotes: 0
Views: 102
Reputation: 248
TRY SOMETHING LIKE BELOW IN YOUR styles.xml
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:textColor">#yourcolor</item>
<item name="android:buttonStyle">@style/ButtonColor</item>
<item name="colorButtonNormal">@color/buttonColor</item>
</style>
<style name="ButtonColor" parent="@android:style/Widget.Button">
<item name="android:textColor">@color/yourcolor</item>
</style>
Upvotes: 1