I am trying to change the background of the action bar via xml, but the action bar is not shown anymore at all.
This is the style that I am using, declared in 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. This is the only styles.xml
file in my app. 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...
For changing background and actionBarStyle from android styling.You can do like this..
<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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.