ActionBar 背景修改问题

来源:互联网 发布:高达软件系统有限公司 编辑:程序博客网 时间:2024/05/16 05:52

ActionBar背景修改不能用文档里的接口:publicabstract void setBackgroundDrawable (Drawabled),这样设置在程序启动的时候程序并没有加载设置的背景图片,而是加载样式默认的图片或者颜色,程序启动之后背景图片只是对原来的背景进行了覆盖必须在样式表里修改背景,如下:


<?xml version="1.0" encoding="utf-8"?> <resources>     <!-- the theme applied to the application or activity -->     <style name="CustomActivityTheme" parent="@android:style/Theme.Holo">         <item name="android:actionBarStyle">@style/MyActionBar</item>         <!-- other activity and action bar styles here -->     </style> <!-- style for the action bar backgrounds -->     <style name="MyActionBar" parent="@android:style/Widget.Holo.ActionBar">         <item name="android:background">@drawable/ab_background</item>         <item name="android:backgroundStacked">@drawable/ab_background</item>         <item name="android:backgroundSplit">@drawable/ab_split_background</item>     </style> </resource>


ActionBar其他特性参源文档:http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2012/1114/554.html