操作栏样式导致操作栏消失。

3

我想对我的操作栏进行主题设计。当我应用我的主题时,在Android Studio的预览中正确地渲染,但在设备上运行时操作栏完全消失了。

我的values/styles.xml文件:

<resources>
    <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
        <item name="android:windowBackground">@color/background_gray</item>
        <item name="android:actionBarStyle">@style/GreenActionBar</item>
    </style>
    <style name="AppTheme" parent="AppBaseTheme"/>

    <style name="GreenActionBarBase">
        <item name="android:background">#00c341</item>
    </style>

    <style name="GreenActionBar" parent="GreenActionBarBase"/>    

</resources>

预览:

预览

运行时:

运行时

我错过了什么?

1个回答

7
<resources>
    <style name="AppBaseTheme" parent="@style/Theme.Holo.Light">
        <item name="android:windowBackground">@color/background_gray</item>
        <item name="android:actionBarStyle">@style/GreenActionBar</item>
    </style>
    <style name="AppTheme" parent="AppBaseTheme"/>

    <style name="GreenActionBarBase" parent="@style/Widget.THE_STYLE_YOU_WANT">
        <item name="android:background">#00c341</item>
    </style>

    <style name="GreenActionBar" parent="GreenActionBarBase"/>    

</resources>

请检查答案。我认为你需要为GreenActionBarBase设置一个父级。


1
是的,事实上我忽略了这一点。谢谢。对于任何未来的搜索者,我选择了Widget.Holo.ActionBar.Solid作为父级。 - sigmabeta

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接