Can I Embed Scrollable Tabs Inside The Action Bar?
I'd like to have a layout where screen real estate is important on smaller screens, but I'd like users to be able to swipe between exactly two tabs. On these smaller screened devi
Solution 1:
You can use Tabs with a ViewPager
and a FragmentPagerAdapter
.
Link them together like so:
@OverridepublicvoidonPageSelected(int position) {
getSupportActionBar().setSelectedNavigationItem(position);
}
@OverridepublicvoidonTabSelected(Tab tab, FragmentTransaction ft) {
mViewPager.setCurrentItem(tab.getPosition());
}
For a more elaborate example check this answer.
Solution 2:
Not only is it possible to support swiping with standard action bar fixed tabs, it's a design guideline:
Use fixed tabs to support quick changes between two or three app views. Fixed tabs should always allow the user to navigate between the views by swiping left or right on the content area.
Scrollable tabs are different than fixed tabs in that the tab bar itself can be scrolled to see more tabs than will fit on the given display:
Post a Comment for "Can I Embed Scrollable Tabs Inside The Action Bar?"