简体   繁体   English

有空间时,上下文操作栏菜单会将项目强制进入溢出菜单

[英]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. 驾驶室上肯定有空间,但是只有一个图标显示,另外两个图标被强制进入oveflow菜单。 If I use android:showAsAction="always" in all three menu items then they all show and there is room. 如果我在所有三个菜单项中都使用android:showAsAction =“ always”,那么它们都会显示并且有空间。 However, I would rather use android:showAsAction="ifRoom" with the result that all three icons show. 但是,我宁愿使用android:showAsAction =“ ifRoom”并同时显示所有三个图标的结果。 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. 已经尝试删除每个项目上的android:title,但是仍然会导致出现oveflow菜单,因此我知道它没有尝试放入标题。

<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. 我使用的图标是每个菜单项的ic_menu_close_clear_cancel。

Has anyone had a similar experience? 有没有人有过类似的经历? What did you do? 你做了什么? Thank you in advance. 先感谢您。

Try using the layoutWeight attribute. 尝试使用layoutWeight属性。 layoutWeight will NOT work with Relative Layout. layoutWeight无法与“相对布局”一起使用。

set the value of layoutWeight between 0 to 1 设置layoutWeight的值在0到1之间

0 - Greedy (Will take the full space) 0-贪婪(会占用全部空间)

1 - Generous (Will take only as much as needed) 1-慷慨(只会按需提供)

Try to fiddle between 0 to 1, and u will hit the spot, try 0.25, or 0.5 for all of them. 尝试在0到1之间摆弄,然后u会达到目的,将所有这些都尝试为0.25或0.5。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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