I'm planning an app to have lots of menu items in landscape mode. However, the menu implementation by android seems to have some limitations causing menu items to hide even with a lot of empty space. According to them, this is because of design principles:
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.
Action bar - ifRoom option leaving too much space
Also:
To override this behavior and have more items, it would be necessary to build a toolbar and have as many buttons as the screen would support. However, I will be reinventing the wheel, because the android menu has a lot of integrations with the device menu button, overflow behavior by collapsing, tooltip by pressing, etc...
Still, I researched some apps and I found that Squid (old Papyrus) does exactly what I seek. It displays far more than what android limits to and it seems to be exactly the android menu behavior but allowing more items.
My question is: What the recommendation to achieve this? Is there a way to overcome the android limitation with a few "hacks" or should I build a whole new custom menu to change a minimal configuration? Can I inflate the android menu and place it somewhere else?
Thanks.
I guess what you need in this situation is to use ActionBar custom view, I don't really know if there is any other way to do that but i know a custom view will do the job, and by the way it's very easy.
See the example bellow:
onCreate():
final ActionBar actionBar = getActionBar();
actionBar.setCustomView(R.layout.custom_view);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
Custom View:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<!-- Your Items -->
</LinearLayout>
Hope this will help.
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.