Android studio can't override default theme

Viewed 303

I'm trying to assign a theme to a button with a custom background. It looks simply like this:

<style name="button">
    <item name="android:background">@drawable/buttonbackground</item>
</style>‌

<Button android:theme="@style/button"/>

The button keeps it's original background, but for TextView, for example, it works.

<TextView android:theme="@style/button"/>

Where's the problem?

2 Answers

change your app theme:

    <style name="Theme" parent="Theme.MaterialComponents.DayNight.NoActionBar.Bridge">
        .....
    </style>

use @style/Theme in the AndroidManifest.xml:

    <application
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/Theme"
        >

Well, it was a very simple solution, just use style instead of android:theme. I just didn't know it existed.

Related