Menu items are been pushed to overflow from contextual action bar when there is room

150 Views Asked by At

I have a contextual action bar with three menu items. There is definitely room on the CAB, but only one item shows and the other two are forced into the oveflow menu. If I use android:showAsAction="always" in all three menu items,nothing happens. they still appear on the overflow. Am using toolbar as the actionbar in my activity which extends AppCompatActivity.

When CAB is shown

CAB ACTIVATED

When overflow is clicked

enter image description here

My menu layout

    <?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/delete_item"
          app:showAsAction="always"
          android:actionLayout="@layout/delete_button"
          android:title="@string/delete">

    </item>

    <item android:id = "@+id/copy_item"
        android:title="@string/copy"
       android:actionLayout="@layout/copy_button"
          app:showAsAction="always">

        </item>

    <item android:id = "@+id/forward"
        android:title="@string/forward"
        android:actionLayout="@layout/forward_button"
          app:showAsAction="always">

    </item>

</menu>

my custom layout for delete menu item (content is the same for all custom layouts of the 3 menu items)

 <?xml version="1.0" encoding="utf-8"?>
<Button
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:drawableTop="@drawable/delete"
    android:text="@string/delete"
    android:id="@+id/menuDelete"
    android:background="@android:color/transparent"
    android:layout_gravity="left"
    android:textSize="14sp"
    android:textColor="@color/blue"
    />

my activity theme

<style name="myTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionModeOverlay">true</item>
        <item name="android:popupBackground">#55acee</item>
        <item name="android:actionMenuTextColor">@android:color/white</item>
        <item name="android:textColorSecondary">@android:color/white</item>
    </style>

Why are my 2 menu items being taken to overflow even when there is space in CAB?

0

There are 0 best solutions below