Reputation: 7547
I have 3 menu icons on the menu bar, but everytime it only shows 2 icons, the last one is in nowhere. my questions are: 1. there is enough space for 3 icons, why only 2 are shown? 2. if the system thinks the space is not enough for the 3rd icon, why doesn't it combine the 2nd and 3rd icon into an overflow menu?
Below is my menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/refresh"
android:icon="@drawable/ic_menu_refresh"
android:showAsAction="ifRoom" />
<item android:id="@+id/add_homework"
android:icon="@android:drawable/ic_menu_edit"
android:showAsAction="ifRoom" />
<item android:id="@+id/set_groupid"
android:icon="@android:drawable/ic_menu_preferences"
android:showAsAction="ifRoom" />
</menu>
and this snippet is in my MainActivity
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu, menu);
return super.onCreateOptionsMenu(menu);
}
Upvotes: 0
Views: 4244
Reputation: 305
I encountered this same issue and resolved it by doing two things, although I think the main reason is the second item. I was using the Android Asset Studio to create icons for my Actionbar menu.
In Android Asset Studio, I set the icon to "trim".
In my menu/activity_main.xml definition file (or whatever you call your menu definition file) I defined my menu icons with android:showAsAction="always"
It looked something like this:
<item android:id="@+id/menu_test"
android:icon="@drawable/ic_menu_test"
android:title="@string/menu_test"
android:showAsAction="always" />
Upvotes: 3
Reputation: 1007554
I have 3 menu icons on the menu bar
For the purposes of this answer, I am assuming that by "menu bar" you are referring to the action bar.
but everytime it only shows 2 icons, the last one is in nowhere
The last one is available by pressing the MENU button, for devices (or emulators) that have an off-screen MENU button.
there is enough space for 3 icons, why only 2 are shown?
Presumably because Android disagrees with your assessment of whether or not there is enough space for 3 icons.
if the system thinks the space is not enough for the 3rd icon, why doesn't it combine the 2nd and 3rd icon into an overflow menu?
I have no idea why you think forcing the 2nd icon -- which, by your admission, fits -- into the overflow menu would be a good idea. The 3rd menu item is in the overflow menu, which is accessed via the MENU button on devices that have one or a three-vertical-dots button on the action bar for devices that lack a MENU button.
Upvotes: 5