简体   繁体   中英

Contextual Action Bar menu forces items into overflow menu when there is room

I have a contextual action bar with three menu items, so only three icons. There is definitely room on the cab, but only one icon shows and the other two are forced into the oveflow menu. If I use android:showAsAction="always" in all three menu items then they all show and there is room. However, I would rather use android:showAsAction="ifRoom" with the result that all three icons show. Have tried deleting android:title on each item, but that still resulted in the oveflow menu, so I know it's not trying to put the title in.

<item android:id="@+id/delete_quiz"
    android:title="DeleteQuiz"
    android:icon="@drawable/ic_menu_close_clear_cancel"
    android:showAsAction="ifRoom"
    />
<item android:id="@+id/load_quiz"
    android:title="LoadQuiz"
    android:icon="@drawable/ic_menu_close_clear_cancel"
    android:showAsAction="ifRoom"
    />
<item android:id="@+id/start_quiz"
    android:title="StartQuiz"
    android:icon="@drawable/ic_menu_close_clear_cancel"
    android:showAsAction="ifRoom"
    />

The icon I'm using is ic_menu_close_clear_cancel for each menu item.

Has anyone had a similar experience? What did you do? Thank you in advance.

Try using the layoutWeight attribute. layoutWeight will NOT work with Relative Layout.

set the value of layoutWeight between 0 to 1

0 - Greedy (Will take the full space)

1 - Generous (Will take only as much as needed)

Try to fiddle between 0 to 1, and u will hit the spot, try 0.25, or 0.5 for all of them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM