【问题标题】:Action Bar Style causes Action Bar to disappear操作栏样式导致操作栏消失
【发布时间】:2014-02-23 00:55:03
【问题描述】:

我正在尝试为我的操作栏设置主题。当我应用我的主题时,预览(在 Android Studio 中)会正确呈现它,但在设备上运行时,Action Bar 完全丢失了。

我的 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>

预览:

运行时:

我错过了什么?

【问题讨论】:

    标签: android android-actionbar android-styles


    【解决方案1】:
    <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 提供父母。

    【讨论】:

    • 是的,这实际上是我忽略的。谢谢。对于任何未来的谷歌员工,我选择了 Widget.Holo.ActionBar.Solid 作为父级。
    猜你喜欢
    • 1970-01-01
    • 2014-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多