When using a ViewPager, is there any advantage to using TabLayout instead of PagerTabStrip or vice versa? Or are they equivalent? Is one more convenient than the other? Does one offer greater functionality? Again all questions are asked, and thus all answers are expected, in the context of ViewPager. Thanks.
Asked
Active
Viewed 1,083 times
2

Katedral Pillon
- 14,534
- 25
- 99
- 199
-
I'd go for tab layout - it is just some months old, so you can be sure it's the one that will be updated and supported through the years. It is material-design-styled. It can be used with any kind of childs and not just as a ViewPager header. – natario Aug 30 '15 at 21:26
-
Also see https://code.google.com/p/android/issues/detail?id=183127 and http://stackoverflow.com/questions/32770917/is-tablayout-supposed-to-replace-pagertabstrip-is-there-any-pro-to-pagertabst – nAndroid Sep 24 '15 at 21:14
-
2Possible duplicate of [Difference between PagerTabStrip and TabLayout](http://stackoverflow.com/questions/35668443/difference-between-pagertabstrip-and-tablayout) – Trung Nguyen Aug 10 '16 at 07:28
1 Answers
0
TabLayout is a material concept that replaced the deprecated ActionBar tabs in Android 5.0. It extends HorizontalScrollView, so you can keep adding tabs horizontally which can include text, icons, or custom views and scroll through them linearly without paging.
TabLayout provides the setupWithViewPager(ViewPager viewPager) method to attach to a ViewPager instead of being part of the ViewPager like the PagerTabStrip.
A PagerTabStrip is more of an indictor for the current page of a ViewPager, and "it is intended to be used as a child view of a ViewPager widget". The scrolling for it does not act like the TabLayout since each tab is part of the page instead of individually horizontally scrollable.

Connecting life with Android
- 3,846
- 4
- 24
- 38