福尔摩斯动作条改变菜单的背景颜色 [英] Sherlock Actionbar change menu background color

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

问题描述

我需要改变的只是菜单项的背景。当我试图用actionBarItemBackground,它改变了应用程序标识的背景为u可以在附件中看到]也。任何帮助或链接将AP preciated。

I need to change the background of menu items only. When I tried with actionBarItemBackground, it changes the background of application logo [As u can see in the attachment] also. Any help or link will be appreciated.

推荐答案

您可以使用自定义布局的动作条项目像这样:

You can use a custom layout for your actionbar item like so:

    <menu xmlns:android="http://schemas.android.com/apk/res/android" >
         <item android:id="@id/item_text"
            android:showAsAction="always"
            android:actionLayout="@layout/action_text"/>
    </menu>

,你想这是设置样式。另一种可能性是只添加了ID(item_text中的例子),并设置背景像这样:

This is styleable as you wish. Another possibility would be adding only the ID (item_text in the example) and set the background like so:

 @Override
 public boolean onPrepareOptionsMenu(Menu menu) {
      MenuItem item = menu.findItem(R.id.item_text);
      item.getActionView().setBackgroundDrawable(new ColorDrawable(/* your color */));

      return super.onPrepareOptionsMenu(menu);
 }

这篇关于福尔摩斯动作条改变菜单的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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