简体   繁体   English

未显示具有自定义背景的操作栏

[英]Action bar with custom background not shown

I am trying to change the background of the action bar via xml, but the action bar is not shown anymore at all. 我正在尝试通过xml更改操作栏的背景,但是该操作栏不再显示。

This is the style that I am using, declared in styles.xml : 这是我使用的样式,在styles.xml声明:

<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
        <item name="actionBarStyle">@style/DiaryActionBar</item>
        <item name="android:actionBarStyle">@style/DiaryActionBar</item>
</style>


<style name="DiaryActionBar"
        parent="@style/Theme.AppCompat.Light.DarkActionBar">
        <item name="background">@color/action_bar_bg</item>
        <item name="android:background">@color/action_bar_bg</item>
</style>

I have set both android:background and background for compatibility. 我已经设置了android:backgroundbackground为兼容。 This is the only styles.xml file in my app. 这是我的应用程序中唯一的styles.xml文件。 What am I doing wrong? 我究竟做错了什么?

In my style with custom actionbar background, i have this: 在具有自定义操作栏背景的样式中,我有以下内容:

<style name="Theme.Malaka" parent="@style/Theme.AppCompat">
<style name="Malaka.ActionBar" parent="@style/Widget.AppCompat.ActionBar">

And that works just fine. 而且效果很好。 Items of the styles are the same as yours. 样式的项目与您的样式相同。 Please note that the parent of Malaka.ActionBar is not Theme... but Widget... 请注意, Malaka.ActionBar的父Malaka.ActionBar不是Theme...而是Widget...

For changing background and actionBarStyle from android styling.You can do like this.. 用于从android样式更改background和actionBarStyle。您可以这样做。

    <style name="AppBaseTheme" parent="@android:style/Theme.Black">
        <item name="android:actionBarStyle">@style/Theme.DeviceDefault.NoActionBar</item>
    </style>

    <style name="DiaryActionBar" parent="@android:style/Theme.Black">
        <item name="android:background">@color/action_bar_bg</item>
    </style>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM