找不到与给定名称'@android:style/Widget.AppCompat.Light.ActionBar.Solid.Inverse'相匹配的资源 [英] No resource found that matches the given name '@android:style/Widget.AppCompat.Light.ActionBar.Solid.Inverse'
问题描述
对不起,我的英语.我尝试更改操作栏科洛尔.而且我有这个错误:
Sorry for my english. I try change action bar collor. And i have this error:
错误:检索项目父项时出错:找不到资源 匹配给定名称'@android:style/ Widget.AppCompat.Light.ActionBar.Solid.Inverse'.
error: Error retrieving parent for item: No resource found that matches the given name '@android:style/ Widget.AppCompat.Light.ActionBar.Solid.Inverse'.
我的minSdkVersion = 12
I have minSdkVersion = 12
style.xml
style.xml
<resources xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android">
<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
//this is error
<style name="MyActionBar" parent="@android:style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#FF9D21</item>
</style>
</resources>
UPD
我添加了appcompat_v7,但是它不起作用
I have added appcompat_v7, but its not work
UPD
现在style.xml看起来:
now style.xml looking that:
<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#FF9D21</item>
</style>
在清单中:
android:theme="@style/MyTheme" >
我有错误:
03-05 12:45:33.860:E/AndroidRuntime(2006): java.lang.RuntimeException:无法启动活动 ComponentInfo {com.example.test6/com.example.test6.MainActivity}: java.lang.IllegalStateException:您需要使用Theme.AppCompat 活动的主题(或后代).
03-05 12:45:33.860: E/AndroidRuntime(2006): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.test6/com.example.test6.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
如果我这样更改清单:
android:theme="@style/Theme.AppCompat" >
没有错误,但是此后没有更改颜色操作栏
no error but after this no change color action bar
推荐答案
改为尝试@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse
.
附带说明, appcompat_v7 上的styles.xml
文件表明已弃用@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse
. @android:style/Widget.DeviceDefault.Light.ActionBar.Solid.Inverse
是替代方法.
On a side note, the styles.xml
file on appcompat_v7 suggests that @style/Widget.AppCompat.Light.ActionBar.Solid.Inverse
is deprecated. @android:style/Widget.DeviceDefault.Light.ActionBar.Solid.Inverse
is an alternative.
这篇关于找不到与给定名称'@android:style/Widget.AppCompat.Light.ActionBar.Solid.Inverse'相匹配的资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!