选项菜单中默认的灰色边框去除

问题描述:

在我的应用我有选项菜单中我尝试定制它,我用它指代的风格做到了,选项菜单中默认的灰色边框去除

我需要的是要么拆除默认的灰色边框的四周选项菜单或自定义它以另一种颜色。

任何意见将不胜感激。

如下图所示:

enter image description here

我的代码:

public boolean onCreateOptionsMenu(android.view.Menu menu) { 

    MenuInflater inflater = getMenuInflater(); 
    inflater.inflate(R.menu.cool_menu, menu); 

    getLayoutInflater().setFactory(new Factory() { 
    public View onCreateView(String name, Context context, 
    AttributeSet attrs) { 

if (name .equalsIgnoreCase("com.android.internal.view.menu.IconMenuItemView")) { 
try { 

    LayoutInflater li = LayoutInflater.from(context); 
    final View view = li.createView(name, null, attrs); 

    new Handler().post(new Runnable() { 
    public void run() { 

    view .setBackgroundResource(R.drawable.border1); 

    ((TextView) view).setTextSize(20); 

    ((TextView) view).setTextColor(Color.RED); 
       } 
      }); 
    return view; } 
    catch (InflateException e) {} 
    catch (ClassNotFoundException e) {} 
     } 
    return null; } 
     }); 
    return super.onCreateOptionsMenu(menu); } 

你试过在看这个问题? How to change the background color of the options menu?你应该可以使用那里的大部分答案来帮助你!

+0

我已经检查过和很多帖子有关的选项菜单,但我无法找到我的目标,谢谢 –

+0

所以你试过'android:panelFullBackground'? – Blundell

+0

@布伦德尔是的,我什么也没有改变。 –