Search code examples
javaandroidandroid-layoutactionbarsherlock

How can I change Menu item size in android?


I created a simple menu item with the help of ActionBarSherlock:

public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(0, ITEMD, 0, "item").setIcon(R.drawable.topbar_btn_inbox).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    MenuInflater inflater = getSupportMenuInflater();
    inflater.inflate(R.menu.breadcrumb_bar_menu, menu);
    return true;
}

But I can't change its width and height. How can I do this in XML or programatically?


Solution

  • As @Tanis.7x stated and according to the Action Bar Icons Documentation size and densities for different devices are already predefined for consistency, so you cant change any. However you can define your custom Action Bar view and then behave like a view and change sizes, etc:

    actionBar = getActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
    actionBar.DISPLAY_SHOW_CUSTOM);
    actionBar.setCustomView(R.layout.custom_view);