Search code examples
androidandroid-activitymenuandroid-fragmentstablet

Android: Design Patterns for Action Bar/Options Menus on Multi-Pane Layouts


From Android Best Practices API Guide: Supporting Tablets and Handsets:

In some cases, you may have one APK to support both a phone and a tablet. Suppose on a phone you have a ListFragment that shows a list of contacts in Activity A, and then a Details fragment that opens in a new Activity, Activity B, when the user selects a contact.

Now on a tablet, we can take advantage of extra real estate by combining the two Fragments into a single, multi-pane Activity, Activity A.

Fragment Design on Tablets/Phones

Consider the application on the phone, again. In Activity A, the options menu might provide a "select all" or "sync contacts" action. Long pressing the items in the list may provide options like "Edit" or "Delete". In Activity B, the options menu can provide actions like "Edit", "Delete", or "Favorite" as well.

How do we consolidate those options on a tablet, however? Do we just consolidate all the options menu items together into one giant menu (1) ? Or do we just discard the Activity B menu and let the user rely on long-tapping the items on the left (2)? One other option is to modify the details fragment to add some of the actions to the details fragment itself (3).

According to the Android Design website, the Contacts app seems to use a combination of 1 and 3. Take a look at http://developer.android.com/design/patterns/multi-pane-layouts.html

So is there a recommended approach, or is it up to the developer?


Solution

  • They can all go in the options menu (or, better yet, action bar), assuming that there will always be at least one item selected in the list in Fragment A. If there are scenarios where Fragment A's list is empty or has no selection, then the story gets a bit more complicated, as B's action bar items all presume the existence of a selection. Ideally, you would not load Fragment B into the activity until there is a selection, in which case Fragment B's action bar items would not appear until they are valid.

    That being said, having slightly different layouts for Fragment B (your option #3) is also reasonable. I am skeptical that it was worth it for the "favorite" star toggle, but, then again, they didn't ask me... :-)

    The one that I definitely disagree with is your option #2. How much you use options #1 or #3 (or a blend) is really up to you.