更改动作条的颜色编程不止一次 [英] Change actionbar color programmatically more than once

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

问题描述

我使用

getSherlockActivity().getSupportActionBar().setBackgroundDrawable(new ColorDrawable(0xff00ACED));

要改变我的操作栏的颜色片段和它的作品。但是,如果我打开这个片段,然后打开另一个片段调用此方法将带有不同颜色的动作条不会更改为所需的颜色。相反,它变成白色,而不是我设置的颜色。

To change the color of my action bar in a fragment and it works. But if i open this fragment then open another fragment that calls this method with a different color the actionbar doesn't change to the desired color. Instead it turns to a white color instead of the color I set it to.

推荐答案

这是一个快速解决方案,我发现

this is a quick fix that i found

mActionBar.setBackgroundDrawable(new ColorDrawable(0xff00DDED));
mActionBar.setDisplayShowTitleEnabled(false);
mActionBar.setDisplayShowTitleEnabled(true);

这篇关于更改动作条的颜色编程不止一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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