【问题标题】:Style showing error in android样式在android中显示错误
【发布时间】:2015-06-23 15:52:59
【问题描述】:

以下样式在eclipse中显示错误

 <style name="AppTheme" parent="android:style/Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primary</item>
    <item name="android:windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
    <item name="colorControlNormal">@color/primary</item>
    <item name="colorControlActivated">@color/primary</item>
    <item name="colorControlHighlight">@color/primary</item>
</style>

<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
    <item name="spinBars">true</item>
    <item name="color">@color/white</item>
</style>

显示这样的错误

error: Error retrieving parent for item: No resource found that matches the given name 'android:style/Theme.AppCompat.Light.NoActionBar'.

当我搜索时,我知道这是依赖关系的问题。我尝试了很多来解决它。但我仍然得到同样的错误。

如果我改变主题没有错误,但我需要这种特殊的风格。

我尝试了以下主题

 <style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">     
     // Your style here

这是醒了。但我需要上述主题。

【问题讨论】:

  • 尝试添加 AppCompat 库
  • 已经试过了。这对我不起作用
  • 删除 android:style/ 并放入 parent="Theme.AppCompat.Light.NoActionBar">
  • 嗯,它对我有用。我在我的依赖项中添加了 'com.android.support:appcompat-v7:+' 并且之前没有 android:style/appended。尝试重建您的项目
  • 不幸的是不适合我。过去两天我被困在这个问题上。

标签: android android-styles


【解决方案1】:

如果你的活动扩展AppCompactActivity,你的父主题应该是

<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light.NoActionBar" />

如果使用ActionBarActivity,主题应该是

<style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar" />

确保您的项目中有set up the dependencies。此功能需要appcompactv7

【讨论】:

  • 我用的是第二个
  • 我在 ans 中添加了一个链接。请检查。
  • 我更新了支持库。之后我应该创建一个新的依赖项吗?
  • 不,它在 Eclipse 中有所不同。只需浏览该页面,您就会明白。
猜你喜欢
  • 2011-02-26
  • 1970-01-01
  • 1970-01-01
  • 2011-08-10
  • 2016-07-02
  • 1970-01-01
  • 1970-01-01
  • 2012-06-30
  • 1970-01-01
相关资源
最近更新 更多