kirilv
kirilv

Reputation: 1431

How to change the position of the overflow menu in Android

How can I change the position of the overflow menu?

This is the menu.xml:

<menu xmlns:android="http://schemas.android.com/apk/res/android"  >
<item
    android:id="@+id/action_fill"
    android:orderInCategory="101"
    android:title="@string/menu_auto_fill"
    android:showAsAction="never" />
<item
    android:id="@+id/action_delete_all"
    android:orderInCategory="102"
    android:title="@string/menu_remove_all"
    android:showAsAction="never" />
<item
    android:id="@+id/action_next"
    android:orderInCategory="100"
    android:icon="@drawable/ic_action_next_item"
    android:title="@string/menu_continue"        
    android:showAsAction="always" />
</menu>

Currently the menu looks like this:

enter image description here

I need it to look like this:

enter image description here

Upvotes: 0

Views: 650

Answers (2)

humblerookie
humblerookie

Reputation: 4957

You cannot change the position of a the designated android overflow menu item, However you could mimic the overflow menu item by placing a similar icon to the left of the rightarrow icon in the action bar and displaying a PopupMenu on its click, which seems to suite your need.

Read more about implementing a PopupMenu here

Upvotes: 2

natario
natario

Reputation: 25194

Just add a submenu:

<menu xmlns:android="http://schemas.android.com/apk/res/android"  >
<item
    android:id="@+id/overflow"
    android:orderInCategory="100"
    android:icon="@drawable/ic_action_overflow"
    android:title="@string/overflow"
    android:showAsAction="always">
    <menu>
        <item
            android:id="@+id/action_fill"
            android:title="@string/menu_auto_fill" />
        <item
            android:id="@+id/action_delete_all"
            android:title="@string/menu_remove_all" />
    </menu>

<item
    android:id="@+id/action_next"
    android:orderInCategory="101"
    android:icon="@drawable/ic_action_next_item"
    android:title="@string/menu_continue"        
    android:showAsAction="always" />
</menu>

Note that this requires you to define the overflow item, with his own icon and so on.

Upvotes: 2

Related Questions