Android Options Menu Icon Won't Display

Android options menu icon won't display

On Android 3.0+, the preferred approach for the options menu (a spillover menu in the action bar) will not show icons. If you have android:targetSdkVersion="11" or higher, icons will never show up in menus on Android 3.0+. The icons will show up if you promote an options menu item to be a toolbar button, and the icons will show up on Android 1.x/2.x devices.

icon in menu not showing in android

If you're running your code on Android 3.0+, the icons in the menu are not shown by design. This is a design decision by Google.

You can read more about it in this on Android developers blog.

why I do not see my Icon in Android Option Menu?

When you are using the ActionBar / Holo theme, you won't see any menu item icons in the overflow menus, sorry.
I think you will get the old menu back when you apply a pre-Holo theme to your activity!

Android toolbar menu is not showing

I'm not sure why, but when i place everything related menu inflating in onPrepareOptionsMenu method, everything works fine.

@Override
public boolean onPrepareOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.dashboard, menu);

return super.onCreateOptionsMenu(menu);
}

Toolbar Won't Show Menu Button

I believe you are talking about the overflow button (labeled '3'):

Sample Image

This button appears when there is not enough room to display all of the items in your options menu, or when you designate specific items to not be shown as an action. This is handled by the app:showAsAction attribute. There are five different values you can apply, which are described as follows:

  • ifRoom : Only place this item in the app bar if there is room for it. If there is not room for all the items marked "ifRoom", the
    items with the lowest orderInCategory values are displayed as
    actions, and the remaining items are displayed in the overflow menu.

  • withText : Also include the title text (defined by android:title) with the action item. You can include this value
    along with one of the others as a flag set, by separating them with a
    pipe |.

  • never : Never place this item in the app bar. Instead, list the item in the app bar's overflow menu.

  • always : Always place this item in the app bar. Avoid using this unless it's critical that the item always appear in the action
    bar. Setting multiple items to always appear as action items can
    result in them overlapping with other UI in the app bar.

  • collapseActionView : The action view associated with this action item (as declared by android:actionLayout or
    android:actionViewClass) is collapsible. Introduced in API Level 14.

Therefore, if you want to only show the overflow button, you should set app:showAsAction="never" for all of your menu items.

Though, the typical structure for an options menu is to always show the first item, and designate the rest to be shown "ifRoom".

The menu item isn't showing in the ActionBar, only in overflow menu

My activity extends ActionBarActivity

As is covered in the documentation, if you are using the appcompat_v7 backport of the action bar, and its associated ActionBarActivity, your menu resource needs to have showAsAction in a namespace custom to your app:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:yourapp="http://schemas.android.com/apk/res-auto" >
<item
android:id="@+id/delete"
yourapp:showAsAction="ifRoom|withText"
android:icon="@drawable/ic_delete_image"
android:title="delete"/>
</menu>

Here is a complete sample project demonstrating the use of the appcompat_v7 action bar.



Related Topics



Leave a reply



Submit