2

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:

enter image description here

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.

enter image description here

Community
  • 1
  • 1
Luccas
  • 4,078
  • 6
  • 42
  • 72

1 Answers1

0

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.

Ahmad Sanie
  • 3,678
  • 2
  • 21
  • 56