Getting started with ActionBar...
For MenuItem.SHOW_AS_ACTION_IF_ROOM
the documentation says:
Show this item as a button in an Action Bar if the system decides there is room for it.
My question is, how does the system decide if there's room, and can I affect/tweak that decision?
In my case, I have a few menu items that would be appropriate to show as action buttons--if there's enough room. On smaller screens they take enough space to make actionbar's title ellipsized. I'd prefer them to go into action overflow in this case, instead of obscuring title.
PS. I am using ActionBarSherlock and haven't checked if native ActionBar acts exactly the same. If native ActionBar doesn't allow "if-room" action items to shrink title too much, then cool, I'll go looking for a bug in ActionBarSherlock.
According to the official Android Design guide (http://developer.android.com/design/patterns/actionbar.html):
Action bar capacity is controlled by the following rules:
- Action buttons in the main action bar may not occupy more than 50% of the bar's width. Action buttons on bottom action bars can use the entire width.
- The screen width in density-independent pixels (dp) determine the number of items that will fit in the main action bar:
- smaller than 360 dp = 2 icons
- 360-499 dp = 3 icons
- 500-599 dp = 4 icons
- 600 dp and larger = 5 icons
OK, this wasn't too hard to figure out, the logic is in ActionMenuPresenter.java
It appears that:
R.integer.abs__max_action_buttons
)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With