【发布时间】:2015-03-05 11:46:29
【问题描述】:
对不起我的英语。我尝试更改操作栏颜色。我有这个错误:
错误:检索项目的父项时出错:找不到资源 匹配给定名称 '@android:style/ Widget.AppCompat.Light.ActionBar.Solid.Inverse'。
我的 minSdkVersion = 12
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,但它不起作用
UPD
现在 style.xml 看起来:
<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:无法启动活动 组件信息{com.example.test6/com.example.test6.MainActivity}: java.lang.IllegalStateException:您需要使用 Theme.AppCompat 此活动的主题(或后代)。
如果我这样更改清单:
android:theme="@style/Theme.AppCompat" >
没有错误,但在此之后没有更改颜色操作栏
【问题讨论】:
-
在您的项目中添加
appcompat_v7。 -
@MD 感谢您的回答,我添加了 appcompat_v7 但不起作用(
-
如果您添加了 appcompat_v7 作为依赖项,那么为什么要在库中添加 .jst?
标签: android xml styles android-manifest