46. Creating a Tabbed Interface using the TabLayout Component

The previous chapter outlined the concept of material design in Android and introduced two of the components provided by the design support library in the form of the floating action button and the Snackbar. This chapter will demonstrate how to use another of the design library components, the TabLayout, which can be combined with the ViewPager2, FragmentStateAdapter, and TabLayoutMediator classes to create a tab based interface within an Android activity.

46.1 An Introduction to the ViewPager2 Class

Although not part of the design support library, the ViewPager2 class is a useful companion class when used in conjunction with the TabLayout component to implement a tabbed user interface. ...

Get Android Studio 4.2 Development Essentials - Java Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.