Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

in my app i have option menu i try to customize it , i did it by refer it to style ,

what i need is either removal of default gray border around option menu or customize it to another color .

any advice will be appreciated .

as shown below :

enter image description here

My code :

 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);   }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
241 views
Welcome To Ask or Share your Answers For Others

1 Answer

Have you tried looking at this question? How to change the background color of the options menu? you should be able to use most of the answers on there to help you!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...