I am using the Action Bar support library (appcompat v7), my app is set to a minimum api of 7, and a target of 21.
I have two styles files, a base one, and one targeted at devices api 11+.
When running the app on a device running KitKat, it seems that android:actionBarStyle
is ignored, leaving the action bar styled as default (@style/Widget.AppCompat.ActionBar.Solid), instead of applying the given background.
But if I remove my v11 styles/comment them out, KitKat listens to the actionBarStyle
attribute set in the base styles.xml file and sets my custom background without any problems.
So my question, where am I going wrong with the v11 styles?
From what I understand, according to the android docs, you are supposed to supply the additional styles for devices running 11+ using the android:
prefix, but this just doesn't seem to be working for me.
Stripped down, this is my /res/values/styles.xml
file:
<style name="My.Theme" parent="@style/Theme.AppCompat">
<item name="actionBarStyle">@style/ActionBar.Solid</item>
</style>
<style name="ActionBar.Solid" parent="@style/Widget.AppCompat.ActionBar.Solid">
<item name="background">@drawable/ab_solid_</item>
</style>
and this is my /res/values-v11/styles.xml
file:
<style name="My.Theme" parent="@style/Theme.AppCompat">
<item name="android:actionBarStyle">@style/ActionBar.Solid</item>
</style>
<style name="ActionBar.Solid" parent="@style/Widget.AppCompat.ActionBar.Solid">
<item name="android:background">@drawable/ab_solid_</item>
</style>
as you can see, the only difference between the two is the use of the android:
prefix.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…