Android Studio 无法覆盖默认主题

标签 android android-studio android-layout

我正在尝试将主题分配给具有自定义背景的按钮。它看起来很简单:

<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/

相关文章:

java.lang.UnsatisfiedLinkError 和 ADB 中的未知错误

Android - 保持选项菜单打开

android: 如何处理 onStop 方法调用

android - 导航组件 - 未生成方向类

Android - 启动时崩溃

android - 拉伸(stretch) ImageView 高度并保持纵横比

android - 在android中的更改 Activity 上滑动xml动画

android - 基于 Sinch FCM 的推送通知

android - gps 对存储在 sqlite 数据库中的一堆位置的近似更改

android-studio - Android资源链接失败。如何解决ic_launcher_foreground.xml文件中的错误?