Widget.AppCompat.Button colorButtonNormal shows gray

Daniel Gomez Rico picture Daniel Gomez Rico · Apr 25, 2015 · Viewed 52.1k times · Source

I have values:styles.xml with:

<style name="AppTheme.Button" parent="Base.Widget.AppCompat.Button">
    <item name="colorButtonNormal">@color/my_color</item>
    <item name="android:textColor">@android:color/white</item>
</style>

and values-v21:styles.xml with:

<style name="AppTheme.Button" parent="Base.Widget.AppCompat.Button">
      <item name="android:colorButtonNormal">@color/my_color</item>
      <item name="android:textColor">@android:color/white</item>
</style>

And app style with

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
      <item name="android:buttonStyle">@style/AppTheme.Button</item>
</style>

But the colors appears grey instead of @color/my_color

Answer

Oleksandr picture Oleksandr · Jun 4, 2015

To customize one button only set android:theme="@style/AppTheme.Button" to your button.

<Button
    android:theme="@style/AppTheme.Button"
    />

Define your style as you did in your question

<style name="AppTheme.Button" parent="Base.Widget.AppCompat.Button">
    <item name="colorButtonNormal">@color/my_color</item>
</style>

[EDIT]

See GitHub demo here