Action bar navigation modes are deprecated in Android L
Now that the Android 5.0 docs are available, we have the official documentation for the Toolbar widget:
A standard toolbar for use within application content.
A Toolbar is a generalization of action bars for use within application layouts. While an action bar is traditionally part of an Activity's opaque window decor controlled by the framework, a Toolbar may be placed at any arbitrary level of nesting within a view hierarchy.
A Toolbar
widget can also be used to replace the action bar:
An application may choose to designate a Toolbar as the action bar for an Activity using the
setActionBar()
method.
The deprecation of tabs in the action bar is most probably due to this, since toolbars cannot contain tab themselves.
Also, it's available for previous Android verions via the appcompat library. See this post by Chris Banes for more information. An excerpt:
Android 5.0 introduces a new Toolbar widget. This is a generalization of the ActionBar pattern but gives you much more control and flexibility in using it. Toolbar is a view in your hierarchy just like any other, making it easier to interleave with the rest of your views, animate, react to scroll events.
It seems like they added a new Class named android.widget.Toolbar
that extends ViewGroup
. Also they added a new method setActionBar(Toolbar)
in Activity
. I haven't tested it yet, but it looks like you can wrap all kinds of TabWidgets
, Spinners
or custom views into a Toolbar
and use it as your Actionbar.
The new Android Design Support Library adds TabLayout, providing a tab implementation that matches the material design guidelines for tabs. A complete walkthrough of how to implement Tabs and ViewPager
can be found in this video
Now deprecated: The PagerTabStrip is part of the support library (and has been for some time) and serves as a direct replacement. If you prefer the newer Google Play style tabs, you can use the PagerSlidingTabStrip library or modify either of the Google provided examples SlidingTabsBasic or SlidingTabsColors as explained in this Dev Bytes video.
The new Toolbar
cannot be used for inflating multiple line objects, so it is impossible to add Tabs to it.
If you want to use a Toolbar
like a TabWidget
you can insert some Tab Objects to it, but only with the old Holo style.
Here there is a custom Library that uses v7 Toolbar
like TabWidget
with the new Material Design animations, but it uses the same methods from the old ActionBar Tabs
, so you can attach your ViewPager
to it.