【问题标题】:How to refer to a theme in style.xml from the AndroidManifest如何从 AndroidManifest 引用 style.xml 中的主题
【发布时间】:2016-07-04 06:13:45
【问题描述】:

我正在尝试为我的 Android 应用程序覆盖主题中的一些值。 AndroidManifest.xml 文件包含以下应用程序声明:

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="App"
    android:supportsRtl="true"
    android:theme="@android:style/AppTheme" >

按照我的风格,我声明了以下主题:

    <style name="AppTheme" parent="@android:style/Theme.Black.NoTitleBar.Fullscreen">
        <item name="android:typeface">serif</item>
    </style>

但是,当我构建项目时,android studio 显示“错误:(28, 24) 未找到与给定名称匹配的资源(在 'theme' 处,值为 '@android:style/AppTheme')。”

如何从清单文件中引用主题?它适用于内置主题(例如 Theme.Black.NoTitleBar.Fullscreen)

【问题讨论】:

    标签: android


    【解决方案1】:

    你只需要使用没有android前缀的@style。像这样:

    android:theme="@style/AppTheme" >
    

    【讨论】:

      【解决方案2】:

      当您使用@android:style 时,您指的是包含在android sdk 中的资源,要使用您自己的资源,您应该只使用@style 或其他资源@drawable、@string 等。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-04-10
        • 2011-05-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-07-15
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多