5

Please take in consideration that I'm refering to the Toolbar Widget(Android L/API 21+) By overflow menu and icons I mean something like this one :

enter image description here

Something more difficult : Is there any way that the icons appear on the RIGHT side of the text?

dejix
  • 1,144
  • 1
  • 12
  • 23

1 Answers1

11

create a menu in menu, for example: main_activity_actions.xml and use this code for the toolbar, try it:

    <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:All4One="http://schemas.android.com/apk/res-auto">
    <item android:id="@+id/algo"//some id
        android:icon="@drawable/kami_nomi_zu_shiru_sekai3" //add the image
        android:title="nose"
        All4One:showAsAction="always">
        <menu>
            <item android:id="@+id/WIFI"//option to display on the menu
                android:icon="@drawable/nisekoi1"//this is a option of the submenu
                android:title="@string/WIFI"/>

            <item android:id="@+id/DATOS"
                android:icon="@drawable/nisekoi6" //this one also is a option
                android:title="@string/DATOS"/>

            <item android:id="@+id/BT"
                android:icon="@drawable/sao1"
                android:title="@string/BT"/>

            <item android:id="@+id/NADA"
                android:icon="@drawable/nisekoi6" //the same
                android:title="@string/NADA"/>
        </menu>
    </item>
</menu>
Carlos Carrizales
  • 2,340
  • 3
  • 18
  • 24
  • Great! Is there any way that the icons appear on the RIGHT side of the text? thx! – dejix May 14 '15 at 22:51
  • to the right side? mm.. i haven't try it, yet! jeje but maybe someone else knows it – Carlos Carrizales May 14 '15 at 22:57
  • There is a bit of an issue with this solution, If top level menu has enough icons that system itself decides to show overflow menu, we then have two overflow menus. – f470071 Feb 20 '17 at 11:02
  • [How To show icons in Overflow menu in ActionBar](https://stackoverflow.com/questions/18374183/how-to-show-icons-in-overflow-menu-in-actionbar) – RonTLV Oct 01 '18 at 05:23