改变安卓:Theme.Light到Theme.AppCompat.Light.DarkActionBar [英] change android:Theme.Light to Theme.AppCompat.Light.DarkActionBar
问题描述
我这是在android的应用程序创建:Theme.Light。我想将其更改为Theme.AppCompat.Light.DarkActionBar,但我得到
没有资源发现指定名称相匹配
theme.appcompat.light.darkactionbar
块引用>我有Android的支持 - v4.jar,当我尝试添加appcompat_v7我得到了codeS错误哪里是类似的东西 - [R .....我可以添加DarkActionBar这个项目没有与$ C $问题CS?如果没有code的变化?
我有:
<资源> <! -
基础应用的主题,依赖于API级别。这个主题被替换
通过AppBaseTheme从RES /值-VXX /较新设备上styles.xml。
- >
<样式名称=AppBaseTheme父=机器人:Theme.Light>
<! -
在新API的级别可以去提供自定义主题
RES /值-VXX / styles.xml,而自定义相关
向后兼容性可以去这里。
- >
< /风格> <! - 应用的主题。 - >
<样式名称=AppTheme父=AppBaseTheme>
<! - 所有自定义不特定于一个特定的API级别的可以去这里。 - >
< /风格>< /资源>我想:
<资源> <! -
基本应用主题API 14+。这个主题完全取代
AppBaseTheme来自RES /价值/ styles.xml和
RES /值-V11 / API上14+设备styles.xml。
- >
<样式名称=AppBaseTheme父=Theme.AppCompat.Light.DarkActionBar>
<! - 14 API自定义主题可以去这里。 - >
< /风格>< /资源>
解决方案确保您的应用程序正确地与支持库相连,与资源(的看到文档这里)。
不要忘了
@style /
:<样式名称=AppTheme父=@风格/ Theme.AppCompat.Light.DarkActionBar>
这将prevent发生在
无资源
错误。
rel=\"nofollow\">本教程的太多,你可能会感兴趣的i have app which was created in android:Theme.Light. i want to change it to Theme.AppCompat.Light.DarkActionBar but i get
no resource found that matches the given name 'theme.appcompat.light.darkactionbar'
I have android-support-v4.jar, when i try add appcompat_v7 i get errors in codes where is something like it R..... Can I add DarkActionBar to this project without problems with codes? Without changes in code?
I have:
<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>
I want:
<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>
解决方案Ensure that your application is properly linked with the Support Library, with resources (see documentation here).
And don't forget
@style/
:<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
This will prevent the
no resource
error from occurring. You might be interested in this tutorial too.这篇关于改变安卓:Theme.Light到Theme.AppCompat.Light.DarkActionBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!