0

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);   }
Android Stack
  • 4,314
  • 6
  • 31
  • 49

1 Answers1

0

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!

Community
  • 1
  • 1
kiwijus
  • 1,217
  • 1
  • 20
  • 40