0

Am creating an app, And when i selecting multiple images, i will show contextual action bar. Eventhough i gave app:showAsAction="always", the menuitem always ends up in overflow.

I had a menu with 5 menu item, in which 3 is showAsAction=always, and other 2 as showAsAction=ifRoom, but am endedUp getting 2 shows as icon, other 3 shows in overflow

Am i doing anything wrong, plz help me.

MyMenu

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/action_add"
        android:icon="@drawable/menu_add"
        android:title="Add"
        app:showAsAction="always" />
    <item
        android:id="@+id/action_select_all"
        android:icon="@drawable/menu_remove"
        android:title="Select All"
        app:showAsAction="always" />
    <item
        android:id="@+id/action_clear"
        android:icon="@drawable/menu_clear"
        android:title="Clear"
        app:showAsAction="always" />
    <item
        android:id="@+id/action_share"
        android:icon="@drawable/menu_share"
        android:title="@string/action_share"
        app:showAsAction="ifRoom" />
    <item
        android:id="@+id/action_delete"
        android:icon="@drawable/menu_delete"
        android:title="@string/action_delete"
        app:showAsAction="ifRoom" />
</menu>
Arun Shankar
  • 612
  • 1
  • 5
  • 16

2 Answers2

1

You can try using android:showAsAction instead of app:showAsAction. If you're using the appcompat_v7 backport, use both android:showAsAction and app:showAsAction. For more details you can refer Items not showing in the ActionBar with showAsAction=“always”

Also make sure that you select a right title for showAsAction , refer Item with app:showAsAction not showing

Hope this helps.

Community
  • 1
  • 1
Neh
  • 442
  • 4
  • 7
0

Show or not show items depends on the space of the screen device. If you don't enough space to show all items, Android put the rest on the overflow menu (even they are declared as app:showAsAction="always" )

Also, you have the android:orderInCategory tag to set a priority within the items.

Hope it helps,

jos
  • 1,070
  • 12
  • 22