2012-05-09 54 views
0

在我的應用我有選項菜單中我嘗試定製它,我用它指代的風格做到了,選項菜單中默認的灰色邊框去除

我需要的是要麼拆除默認的灰色邊框的四周選項菜單或自定義它以另一種顏色。

任何意見將不勝感激。

如下圖所示:

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); } 

回答

0

你試過在看這個問題? How to change the background color of the options menu?你應該可以使用那裏的大部分答案來幫助你!

+0

我已經檢查過和很多帖子有關的選項菜單,但我無法找到我的目標,謝謝 –

+0

所以你試過'android:panelFullBackground'? – Blundell

+0

@布倫德爾是的,我什麼也沒有改變。 –