如何改变动作条的颜色? [英] How to change ActionBar color?

查看:130
本文介绍了如何改变动作条的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何可以改变动作条的颜色? 我Implemeted一个这个和它的作品,但不是我想要的。它改变颜色活动开始后才能,应用程序后,这样对启动原条的颜色显示,只有一秒钟后我的自定义颜色dislpayed。是否有任何其他的方法来处理这​​个问题? 在此先感谢

  ....
保护无效的onCreate(包savedInstanceState){
    super.onCreate(savedInstanceState);
    动作条动作条;
    actionBar.setBackgroundDrawable(新ColorDrawable(Color.parseColor(#879f38)));
.....
 

解决方案

创建一个主题:

 <样式名称=Theme.MyAppTheme父=@安卓风格/ Theme.Holo>
    <项目名称=机器人:actionBarStyle> @风格/ Theme.MyAppTheme.ActionBar< /项目>
< /风格>

<样式名称=Theme.MyAppTheme.ActionBar父=@安卓风格/ Widget.Holo.ActionBar>
    <项目名称=机器人:背景>#222222< /项目>
< /风格>
 

How could I change ActionBar color? I've implemeted this and it works but not as I want. it changes color only after activity started, so right after app launch the original bar colour is showed, and only a second later my custom color is dislpayed. Is there any other way to handle that? Thanks in advance

....
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);  
    ActionBar actionBar;
    actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#879f38")));
.....

解决方案

Create a Theme:

<style name="Theme.MyAppTheme" parent="@android:style/Theme.Holo">
    <item name="android:actionBarStyle">@style/Theme.MyAppTheme.ActionBar</item>
</style>

<style name="Theme.MyAppTheme.ActionBar" parent="@android:style/Widget.Holo.ActionBar">
    <item name="android:background">#222222</item>
</style>

这篇关于如何改变动作条的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆