首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将android:Theme.Light更改为Theme.AppCompat.Light.DarkActionBar

将android:Theme.Light更改为Theme.AppCompat.Light.DarkActionBar
EN

Stack Overflow用户
提问于 2014-05-20 21:55:05
回答 2查看 8.2K关注 0票数 0

我有一个应用程序,是用android:Theme.Light创建的。我想把它改成Theme.AppCompat.Light.DarkActionBar,但我得到了

没有找到与给定名称“theme.appcompat.light.darkactionbar”匹配的资源

我有android-support-v4.jar,当我尝试添加appcompat_v7时,我会得到代码中的错误,比如R.我可以将DarkActionBar添加到这个项目中吗?不改变代码?

我有:

代码语言:javascript
复制
<resources>

    <!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
    -->
    <style name="AppBaseTheme" parent="android:Theme.Light">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    </style>

</resources>

我要:

代码语言:javascript
复制
<resources>

    <!--
        Base application theme for API 14+. This theme completely replaces
        AppBaseTheme from BOTH res/values/styles.xml and
        res/values-v11/styles.xml on API 14+ devices.
    -->
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- API 14 theme customizations can go here. -->
    </style>

</resources>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-05-20 22:00:41

确保应用程序与支持库( Support )、资源(见这里的文档)正确链接。

别忘了@style/

代码语言:javascript
复制
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">

这将防止发生no resource错误。您可能也对本教程感兴趣。

票数 2
EN

Stack Overflow用户

发布于 2014-05-20 22:00:13

如果您正在清单中执行此操作,请执行以下操作以设置整个应用程序的主题:

代码语言:javascript
复制
 <application
    ...
    android:theme="@style/Theme.AppCompat.Light.DarkActionBar" 
    ...>

在特定主题的XML中,您需要@style,因此放置以下内容:

代码语言:javascript
复制
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23770641

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档