android - actionBar background doesn't change -
so i'm new app developing , next developer's guide on android.com. i'm stuck on "stylizing actionbar" part, because code suggested on website doesn't work:
<?xml version="1.0" encoding="utf-8"?> <resources> <!-- theme applied application or activity --> <style name="customactionbartheme" parent="@style/theme.appcompat.light.darkactionbar"> <item name="android:actionbarstyle">@style/myactionbar</item> <!-- back upwards library compatibility --> <item name="actionbarstyle">@style/myactionbar</item> </style> <!-- actionbar styles --> <style name="myactionbar" parent="@style/widget.appcompat.light.actionbar.solid.inverse"> <item name="android:background">@drawable/actionbar_background</item> <!-- back upwards library compatibility --> <item name="background">@drawable/actionbar_background</item> </style> </resources>
i compatibility error android:backgound can't used since minsdk 7 (though guide claims should work). don't want alter minsdk, , tried splitting themes.xml 2, 1 set values, , other values-v11. error doesn't occur anymore, when run app actionbar doesn't alter backgroud. here both files:
this 1 in values
<?xml version="1.0" encoding="utf-8"?> <resources> <!-- theme applied application or activity --> <style name="customactionbartheme" parent="@style/theme.appcompat.light.darkactionbar"> <!-- back upwards library compatibility --> <item name="actionbarstyle">@style/myactionbar</item> </style> <style name="myactionbar" parent="@style/widget.appcompat.light.actionbar.solid.inverse"> <!-- back upwards library compatibility --> <item name="background">@drawable/actionbar_background</item> </style> </resources>
and 1 in values-11
<?xml version="1.0" encoding="utf-8"?> <resources> <!-- theme applied application or activity --> <style name="customactionbartheme" parent="@style/theme.appcompat.light.darkactionbar"> <item name="android:actionbarstyle">@style/myactionbar</item> </style> <style name="myactionbar" parent="@style/widget.appcompat.light.actionbar.solid.inverse"> <item name="android:background">#ffb300</item> </style> </resources>
do have thought what's problem here?
the api lvl on device 21
as of appcompat v21, android:
attributes no longer used. supports color theming, provides easy way set color of action bar (and status bar on android 5.0 devices) using simple theme:
<style name="theme.mytheme" parent="theme.appcompat.light"> <!-- colorprimary used default action bar background --> <item name="colorprimary">@color/my_awesome_color</item> <!-- colorprimarydark used status bar --> <item name="colorprimarydark">@color/my_awesome_darker_color</item> <!-- coloraccent used default value colorcontrolactivated used tint widgets --> <item name="coloraccent">@color/accent</item> <!-- can set colorcontrolnormal, colorcontrolactivated colorcontrolhighlight & colorswitchthumbnormal. --> </style>
android
No comments:
Post a Comment