androidandroid-menuandroid-toolbar

Android Toolbar Popup menu not showing icons


I am trying to show a drop down menu for my toolbar which includes BOTH text and icons:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto">

    <item
        android:id="@+id/menu_add"
        android:title="@string/menu.add"
        android:icon="@drawable/ic_add_black_24dp"
        app:showAsAction="always" />

    <item
        android:id="@+id/menu_edit"
        android:title="@string/menu.edit"
        android:icon="@drawable/ic_create_black_24dp"
        app:showAsAction="never" />

</menu>

The menu_add does show with the icon on the toolbar itself but the menu_edit only shows the text without the icon.

This answer: https://stackoverflow.com/a/19750717/197127 says that Google has removed it by design but does not refer to how you may override it.

Edit

I also need the device "menu" button to show the same menu.


Solution

  • I found this solution: https://stackoverflow.com/a/30337653/197127. Basically, overriding a method and it does not break the device menu button or the overflow. Thanks to all.