Android: how to change action bar background color

2019-04-01 23:53发布

The color of my android application is black. I wish to change it to other color. What is the easiest way to do it? I have tried to make a theme from this link

When the application is opened, I could see that the action bar has changed the color from black to other color but in about 3 seconds, there is a message: Unfortunately, .... has stopped. I wish to use an easier way to may it. Any help is greatly appreciated.

2条回答
The star\"
2楼-- · 2019-04-02 00:32

To apply the theme to all activities, change the style.xml like this:

<style name="AppTheme" parent="android:Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/ActionBarTheme</item>
</style>

<style name="ActionBarTheme" parent="android:Widget.Holo.Light.ActionBar.Solid.Inverse">
    <item name="android:background">@color/action_bar</item>
</style>

And in colours.xml, use:

<color name="action_bar">#BA0000</color>

And in the manifest:

<application
    android:theme="@style/AppTheme" >
查看更多
姐就是有狂的资本
3楼-- · 2019-04-02 00:32

if you want change the color of ActionBar just do this:

 ActionBar bar = getActionBar();
 bar.setBackgroundDrawable(new ColorDrawable("COLOR"));

see the following link for more info

查看更多
登录 后发表回答