夏洛克操作栏的菜单项背景 [英] Sherlock action bar's menu item background

查看:207
本文介绍了夏洛克操作栏的菜单项背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有夏洛克动作条渲染自定义视图的问题。什么情况是我已经成功地设置旨在设置中心标题TextView的操作栏中的自定义视图,但是当我设置刷新一样的其他菜单项,然后它的背景出现带有黑色。同样的事情发生与家庭按钮。请通过以下快照。

i am having issue with rendering custom view in Sherlock action bar. what happen is i've successfully set the custom view in action bar designed to set the Title textview in center, but when i set the other menu items like refresh then it's background appears with black color. same things happens with home button. please go through the following snapshot.

你可以在此图像中看到当我设置主页按钮可见或设置不应该用黑色背景中显示这样的刷新菜单项。

as you can see in this image when i set home button visible or set the refresh menu item it should not displayed like this with black background.

在我的活动屏幕

protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.menu_activity);
   .... 
   View customNav = LayoutInflater.from(this).inflate(R.layout.custom_navigation, null);
   TextView textView = (TextView)customNav.findViewById(R.id.screen_title);
   textView.setText("Category");
   getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
   getSupportActionBar().setCustomView(customNav);
   getSupportActionBar().setDisplayHomeAsUpEnabled(true);
   getSupportActionBar().setDisplayShowHomeEnabled(true);   
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(0,Constants.REFRESH_ITEM_ID,0,Constants.LABEL_REFRESH)
        .setIcon(R.drawable.ic_refresh)
        .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    return true;
}

我已经尝试了很多,但未能解决it.Please帮助我。
先谢谢了。

I've tried a lot but fail to fix it.Please help me. Thanks in Advance.

推荐答案

看来你在整个应用程序或本次活动清单文件使用Theme.Sherlock.Dark。
这是ActionBar中的正常行为 - 它是由样式定义,但你的自定义视图元素已经是自己的底色,文字风格等...
从setCustomView()的javadoc:

It seems you use Theme.Sherlock.Dark in manifest file for whole application or this activity. It is normal behavior of ActionBar -- it is defined by style, but your custom view-element has is own backround, text style, etc... From setCustomView() javadoc:

自定义导航视图的应用程序图标,任何操作按钮之间出现,可以使用任何可用空间在那里。

Custom navigation views appear between the application icon and any action buttons and may use any space available there.

此方法只需要添加新的观点吧,但不设置鉴于整个酒吧。

This method just add new view to bar, but doesn't set 'view for whole bar'.

看看 http://jgilfelt.github.com/android-actionbarstylegenerator - - 这是动作条的样式发生器。注意切换按钮风格的兼容性。

Take a look at http://jgilfelt.github.com/android-actionbarstylegenerator -- this is a style generator for action bar. Pay attention to the toggle button "Style compatibility".

这篇关于夏洛克操作栏的菜单项背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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