java - 覆盖默认的 Android 主题

标签 java android

我已经能够覆盖名称前面带有“android:”的任何主题,但 Android themes.xml 还定义了似乎无法覆盖的属性。例如:

<!-- Variation on the Light theme that turns off the title -->
<style name="Theme.Codebase" parent="android:style/Theme.Light">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="colorBackground">@color/off_white</item>
</style>

colorBackground 是在 Theme.Light xml 中定义的,但是在这里添加它会给我一个

/res/values/styles.xml:10: error: Error: No resource found that matches the given name: attr 'colorBackground'.

错误。如何覆盖整个应用程序的样式?

最佳答案

您可以像修改 windowNoTitle 等属性一样覆盖标准属性,只是不要忘记像这样添加 android: 前缀:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="SEclubTheme" parent="@android:style/Theme">
        <item name="android:colorForeground">@color/bright_foreground_dark</item>
        <item name="android:colorBackground">@color/background_dark</item>
    </style>
</resources>

关于java - 覆盖默认的 Android 主题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4833947/

相关文章:

java - ListAdapter 和 Fragment 之间的接口(interface)

java - 我无法在 Android-Studio 上使用 TensorFlow 创建实例

java - 为什么RecyclerView没有显示任何项目?

按参数类型转换的 Java 泛型

java - 我可以在与主代码相同的类中进行 jUnit 测试吗?

Java:单线程修改对象,多线程读取

java - JDBC 访问被拒绝错误

java - Android循环倒计时

android - Gradle构建速度

java - 使用 onclick 或 ID 执行方法?