Android: how to change action bar background color? [closed]

蹲街弑〆低调 提交于 2019-12-21 06:19:30

问题


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.


回答1:


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" >



回答2:


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



来源:https://stackoverflow.com/questions/20440121/android-how-to-change-action-bar-background-color

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!