I want to change the style of my Action bar so I want to change the color of line under the action bar from Blue to Orange , how can I do that?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
There is a good tutorial here
Create a new style with your custom drawable
<?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>
then in AndroidManifest.xml add the custom style
<application
android:debuggable="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.MyStyle"
>
<activity ...>
<activity .../>
...
</application>
回答2:
If you want change it by code, you could try this:
getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.myninepatch));