What are the official Android recommendations for

2019-02-15 15:30发布

问题:

I have to say I'm pretty lost when it comes to designing tabbed layouts on Android right now. The platform developers seem to be evolving the design faster than I can figure out their intentions.

From what I can gather from the combination of the recently deprecated TabActivity and the new design guide, I think they intend for tabs to be exclusively with the Action Bar, either inside the main action bar or stacked on a secondary action bar.

Though the developer's guide suggests using the Action Bar for "global navigation". Does this mean that it's recommended to create your own tabs outside the Action Bar if your tabs only apply to a particular application context?

回答1:

"Global" is used in a local context here. :) The intent of that statement is to say that action bar tabs should be used for activity-global navigation, and that you should refrain from using action bar tabs to switch navigation within a sub-pane of the same activity.

This mostly applies to large-screen or tablet layouts where you might have multiple panes of content. If you use action bar tabs in such a configuration, it wouldn't make sense for those tabs to only apply to the right detail pane of the activity but leave a left pane alone. If you wanted tabs that only apply to a single pane of an activity, those tabs should be part of that pane rather than part of the action bar.

Basically, tabs should always be local to the content that they affect. If switching tabs switches between different content for the whole activity window, use action bar tabs. If tabs are more local to a smaller part of your UI, place them closer to the content that will actually change when you select a new tab.