Action bar - ifRoom option leaving too much space

前端 未结 3 1737
小蘑菇
小蘑菇 2020-12-20 11:41

I have a problem on my Action bar, I tried to setup a search view on it in order to get a a search bar expandable.

This is woking well except the fact that I had to

相关标签:
3条回答
  • 2020-12-20 12:02

    In the XML file, you can request a MenuItem to appear as an action item by declaring android:showAsAction="ifRoom" for the <item> element. This way, the MenuItem appears in the ActionBar for quick access only if there is room available. If there's not enough room, the item appears in the overflow menu.

    so you answer is:

    use "ifRoom" to request that an item appear in the action bar, but allow the system to move it into the overflow menu when there's not enough room.(when space is limited on smaller screens).

    You can use android:showAsAction="always" to show all menu in ActionBar.

    0 讨论(0)
  • 2020-12-20 12:03

    The maximum of icons for "ifRoom" option is 5 (five) even when I moved to my 100 inch screen size tablet :-) and desperately rotate it on landscape see the link from Jake Wharton's answer (Thank you !) http://developer.android.com/design/patterns/actionbar.html

    0 讨论(0)
  • 2020-12-20 12:10

    Looks like its a design decision:

    Jake Wharton Says:

    When contained within the action bar there is a finite maximum of action items based on the device's density-independent width. The action items can also not cover more than half the width of the action bar.

    From here.

    0 讨论(0)
提交回复
热议问题