【问题标题】:No resource found that matches the given name '@android:style/Widget.AppCompat.Light.ActionBar.Solid.Inverse'找不到与给定名称“@android:style/Widget.AppCompat.Light.ActionBar.Solid.Inverse”匹配的资源
【发布时间】: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


【解决方案1】:

改用@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse

在旁注中,the styles.xml file on appcompat_v7 建议 @style/Widget.AppCompat.Light.ActionBar.Solid.Inverse 已弃用。 @android:style/Widget.DeviceDefault.Light.ActionBar.Solid.Inverse 是另一种选择。

【讨论】:

【解决方案2】:

我的 v21\styles.xml 文件中有这个问题。

解决方案:

parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse"

【讨论】:

    【解决方案3】:

    这对我有用

    <style name="AppBarStyle" parent="@android:style/Widget.DeviceDefault.Light.ActionBar.Solid.Inverse">
    

    【讨论】:

      猜你喜欢
      • 2016-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-26
      • 2017-08-26
      相关资源
      最近更新 更多