如何改变编程的操作栏项目的背景颜色 [英] How to change programmatically background color of action bar items

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

问题描述

这是很容易设置来设置的操作栏中的项目背景默认颜色:

It is easy to set a default color of the items background in action bar by setting:

<item name="android:actionBarItemBackground">@drawable/action_bar_item_background</item>

在应用程序的主题。

我想改变这种颜色只为我的片段之一。如何做到这一点编程?

I would like to change this color only for one of my fragments. How to do it programmatically?

推荐答案

你试过从user3225831解决方案 这里所说的:<一href="http://stackoverflow.com/a/21297231/1738838">http://stackoverflow.com/a/21297231/1738838

Have you tried the solution from user3225831 mentioned here: http://stackoverflow.com/a/21297231/1738838

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

这篇关于如何改变编程的操作栏项目的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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