Android options menu icon won't display

前端 未结 3 818
夕颜
夕颜 2020-11-29 09:10

I\'m following a book on Android Development to get myself started writing my first real app. I got up to the point where I\'m making an options menu for one of my activitie

相关标签:
3条回答
  • 2020-11-29 09:48

    A good idea is that you created a layout with RelativeLayout and when user selected your menu, your layout is displayed.

    0 讨论(0)
  • 2020-11-29 09:59

    This is perfectly working for me in API 23

    <menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".MainActivity">
    <item
        android:icon="@drawable/ic_menu"
        android:orderInCategory="100"
        android:title="Option Menu"
        app:showAsAction="always">
        <menu>
            <item
                android:id="@+id/action_myorder"
                android:icon="@drawable/ic_order"
                android:title="My Order" />
            <item
                android:id="@+id/action_myaccount"
                android:icon="@drawable/ic_account"
                android:title="My Account" />
            <item
                android:id="@+id/action_share"
                android:icon="@drawable/ic_share"
                android:title="Share" />
            <item
                android:id="@+id/action_term_condition"
                android:icon="@drawable/ic_terms"
                android:title="Term and Conditions" />
            <item
                android:id="@+id/action_logout"
                android:icon="@drawable/ic_logout"
                android:title="Logout" />
        </menu>
    </item>
    

    0 讨论(0)
  • 2020-11-29 10:11

    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.

    0 讨论(0)
提交回复
热议问题