Bottom Navigation & Tabs
Implement multi-section navigation with BottomNavigationView connected to NavController, and swipeable tabs with TabLayout, ViewPager2, and TabLayoutMediator.
Navigation Patterns
Two common patterns for top-level navigation in Android apps:
- Bottom Navigation — for 3–5 primary destinations. Always visible. Best for equal-importance sections (e.g., Home, Search, Profile).
- Tabs — for related content within a screen (e.g., All / Active / Done). Often used with ViewPager2 for swipe support.
BottomNavigationView Layout
Add BottomNavigationView and a FragmentContainerView to your Activity layout:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/navHostFragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
app:navGraph="@navigation/nav_graph"
app:defaultNavHost="true" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottomNav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:menu="@menu/bottom_nav_menu" />
</LinearLayout>All lessons in this course
- Material Design Basics
- Themes & Styles
- Custom Views
- Animations & Transitions
- Bottom Navigation & Tabs