Introducing tabbed navigation
Tabbed navigation is mostly used when you want to display related items. It is common to have fixed tabs if there are only a few of them (typically between three and five tabs) and scrolling horizontal tabs if you have more than five. They are used mostly for grouping destinations that are at the same hierarchical level.
This might be the case if the app you are developing has a narrow or specific subject field where the primary destinations are related, such as a news app. More commonly, it is used with bottom navigation to present secondary navigation that’s available within a primary destination.
Exercise 4.4 – Using tabs for app navigation
The following exercise demonstrates using scrollable tabbed navigation to create a news app:
- Open Android Studio and select New Project on the Android welcome screen. Select Empty Activity and call it
Tab Navigation
. - Create the
Screens.kt
file and add theContentScreen
...