我正在尝试将主题分配给具有自定义背景的按钮。它看起来很简单:
<style name="button">
<item name="android:background">@drawable/buttonbackground</item>
</style>
<Button android:theme="@style/button"/>
该按钮保持其原始背景,但对于 TextView,例如,它可以工作。<TextView android:theme="@style/button"/>
问题出在哪里?
最佳答案
更改您的应用主题:
<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"
>
关于Android Studio 无法覆盖默认主题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68400482/