在Android中设置样式

时间:2013-09-29 16:35:39

标签: android

嘿伙计我是Android新手,我对我正在进行的项目有疑问:

使用这些样式设置actionbar的样式:

<resources>
    <!-- the theme applied to the application or activity -->
    <style name="CustomActionBarTheme"
           parent="@style/Theme.Holo.Light.DarkActionBar">
        <item name="android:actionBarStyle">@style/MyActionBar</item>
    </style>

    <!-- ActionBar styles -->
    <style name="MyActionBar"
           parent="@style/Widget.Holo.Light.ActionBar.Solid.Inverse">
        <item name="android:background">@drawable/actionbar_background</item>
    </style>
</resources>

我发现这两种风格都有错误,他们说:

error: Error retrieving parent for item: No resource found that matches the given name '@style/
 Theme.Holo.Light.DarkActionBar'.

error: Error retrieving parent for item: No resource found that matches the given name '@style/
 Widget.Holo.Light.ActionBar.Solid.Inverse'.

我将这些文件放在一个名为themes的单独XML文件中。在我的样式XML文件中,我有主题android:Theme.Light

如果你能给我一个建议或什么错误,我会很感激!

大卫

1 个答案:

答案 0 :(得分:2)

"@style/Theme.Holo.Light.DarkActionBar"

您指的是values / styles.xml中的样式,并且您没有styles.xml中提到的样式。你可能意味着引用android风格包中的那个,如@android:style/..

更改为

 <resources>
    <style name="CustomActionBarTheme" parent="@android:style/Theme.Holo.Light.DarkActionBar">
             <item name="android:actionBarStyle">@style/MyActionBar</item>

    </style>

    <style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
         <item name="android:background">@drawable/actionbar_background</item>

    </style> 
</resources>
相关问题