1

I'm using Android Studio with min API level 23 and targeting API 28.

I defined a theme in styles.xml as follows. Colors are all valid and present.

<style name="GreatButton" parent="Widget.AppCompat.Button.Colored">
    <item name="colorButtonNormal">@color/orange_900</item>
    <item name="colorAccent">@color/blue_900</item>
    <item name="android:textColor">@color/white</item>
</style>

I have this theme as a global for all Buttons with buttonStyle (tried android:buttonStyle too)

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
      <item name="colorPrimary">@color/colorPrimary</item>
      <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
      <item name="colorAccent">@color/colorAccent</item>
      <item name="buttonStyle">@style/GreatButton</item>
    </style>

I have three buttons in my Activity (which inherits from AppCompatActivity). Of these only one button has the theme explicitly specified

 android:theme="@style/GreatButton"

This is how the buttons render

enter image description here

As you can see, the theme fully applied to the first button- one for which I specifically applied it (blue background and white text). The same theme partially applied (white text) to the other buttons and for background color, it defaulted to the default behavior for coloredButton which is to have background for enabled buttons to be of @color/colorAccent (pink in my case)

So why does the global button theme apply only partially (just text color) when obviously the syntax is right (as can be evidenced from the theme applying correctly when explicitly specified for a button)?

Edit: This is not a duplicate as noted in comments

Stubborn
  • 290
  • 2
  • 17
  • Possible duplicate of [How to change android button text color globally in theme](https://stackoverflow.com/questions/36261421/how-to-change-android-button-text-color-globally-in-theme) – Adil Mar 04 '19 at 09:28
  • No it is not. Specifically the newer(material design) solution mentioned there and elsewhere is not working fully for me as described above – Stubborn Mar 04 '19 at 13:21

0 Answers0