我想改变我的行动吧的风格,所以我想改变操作栏从蓝到橙色线下的颜色,我该怎么办呢?
Answer 1:
这是一个很好的教程在这里
与您的自定义绘制创建一个新的风格
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="Theme.MyStyle" 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>
</resources>
然后在AndroidManifest.xml中添加自定义风格
<application
android:debuggable="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.MyStyle"
>
<activity ...>
<activity .../>
...
</application>
Answer 2:
如果你想通过代码改变它,你可以试试这个:
getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.myninepatch));
文章来源: How can I change the style of action bar API 15