Search code examples
androidandroid-theme

android:background not work on button with theme Theme.MaterialComponents.DayNight.DarkActionBar


android:background and android:textColor not working on Button when application theme is "Theme.MaterialComponents.DayNight.DarkActionBar", but is works when theme "Theme.MaterialComponents.DayNight.DarkActionBar.Bridge".

I want to know why and how to fix this issue without changing the theme.


Solution

  • Ref:https://material.io/develop/android/docs/getting-started/

    Bridge themes inherit from AppCompat themes, but also define the new Material Components theme attributes for you.

    So if your button is not changing according to your wish you can use one of the bridge themes.

    Theme.MaterialComponents.Bridge
    Theme.MaterialComponents.Light.Bridge
    Theme.MaterialComponents.NoActionBar.Bridge
    Theme.MaterialComponents.Light.NoActionBar.Bridge
    Theme.MaterialComponents.Light.DarkActionBar.Bridge