我正在尝试为具有自定义背景的按钮分配一个主题。它看起来很简单:
<style name="button">
<item name="android:background">@drawable/buttonbackground</item>
</style>
<Button android:theme="@style/button"/>
按钮保持其原始背景,但对于 TextView,例如,它有效。
<TextView android:theme="@style/button"/>
问题出在哪里?
答案 0 :(得分:0)
更改您的应用主题:
<style name="Theme" parent="Theme.MaterialComponents.DayNight.NoActionBar.Bridge">
.....
</style>
在 AndroidManifest.xml 中使用 @style/Theme:
<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme"
>
答案 1 :(得分:0)
嗯,这是一个非常简单的解决方案,只需使用 style
而不是 android:theme
。我只是不知道它存在。