Skip to main content
Android UI Design with Kotlin
CHAPTER 12 Beginner

Bottom Navigation and Tab Layouts

Updated: May 31, 2026
5 min read

# CHAPTER 12

Bottom Navigation and Tab Layouts

1. Introduction

As smartphones have grown taller, reaching the top of the screen to open a menu has become a physical chore. Modern mobile UX solves this by moving primary navigation to the bottom of the screen, right under the user's thumb. In this chapter, we will design intuitive, accessible navigation using BottomNavigationView for top-level destinations, and TabLayout for organizing sub-categories.

2. Learning Objectives

By the end of this chapter, you will be able to:
  • Understand when to use Bottom Navigation vs. Navigation Drawers.
  • Implement a BottomNavigationView using XML menus.
  • Style bottom navigation bars to match your brand.
  • Implement a TabLayout for swiping between categories.
  • Combine TabLayout with a ViewPager (or ViewPager2) for seamless swiping.

3. BottomNavigationView Basics

A Bottom Navigation bar should display 3 to 5 top-level destinations. If you have fewer than 3, use Tabs. If you have more than 5, use a Navigation Drawer.

Step 1: Create the Menu XML Create a menu file (e.g., bottomnavmenu.xml) in the res/menu folder:

xml
1234567891011121314
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/nav_home"
        android:icon="@drawable/ic_home"
        android:title="Home" />
    <item
        android:id="@+id/nav_search"
        android:icon="@drawable/ic_search"
        android:title="Search" />
    <item
        android:id="@+id/nav_profile"
        android:icon="@drawable/ic_person"
        android:title="Profile" />
</menu>

Step 2: Add to Layout Place the BottomNavigationView at the bottom of your main layout (using a ConstraintLayout or RelativeLayout).

xml
123456
<com.google.android.material.bottomnavigation.BottomNavigationView
    android:id="@+id/bottomNavigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:menu="@menu/bottom_nav_menu"
    app:layout_constraintBottom_toBottomOf="parent" />

4. Customizing Bottom Navigation

You can style the navigation bar to look modern and flat.
  • app:itemIconTint: Set a color state list to change the color of the active vs. inactive icons.
  • app:itemTextColor: Change the text color based on state.
  • app:labelVisibilityMode: Choose whether the text labels always show, never show, or only show on the selected item (selected mode is a very popular modern design pattern).

5. TabLayout for Sub-Navigation

While Bottom Navigation is for moving between completely different sections of an app, Tabs are used to organize related data on the *same* screen (e.g., "Chats", "Status", and "Calls" in a messaging app).
xml
123456
<com.google.android.material.tabs.TabLayout
    android:id="@+id/tabLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:tabMode="fixed"
    app:tabGravity="fill" />
  • app:tabMode="fixed": All tabs fit on the screen equally.
  • app:tabMode="scrollable": Useful if you have many tabs; the user can swipe horizontally to see more tabs.

6. Combining TabLayout with ViewPager2

A TabLayout usually doesn't exist alone. Users expect to be able to swipe the screen left or right to switch tabs. This is achieved using a ViewPager2. You place the ViewPager2 below the TabLayout in your XML, and then link them together in your Kotlin code using TabLayoutMediator.

7. Mini Project: Multi-Screen Navigation

Let's build the XML for a screen that has an AppBar, a TabLayout below it, a ViewPager taking up the middle, and a BottomNavigationView at the bottom.
xml
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <!-- Top AppBar -->
    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/appBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toTopOf="parent">
        
        <androidx.appcompat.widget.Toolbar
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:title="Messages" />

        <!-- TabLayout directly below Toolbar -->
        <com.google.android.material.tabs.TabLayout
            android:id="@+id/tabLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabTextColor="#B3FFFFFF"
            app:tabSelectedTextColor="#FFFFFF"
            app:tabIndicatorColor="#FFFFFF" />
            
    </com.google.android.material.appbar.AppBarLayout>

    <!-- ViewPager for swiping screens -->
    <androidx.viewpager2.widget.ViewPager2
        android:id="@+id/viewPager"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintTop_toBottomOf="@+id/appBar"
        app:layout_constraintBottom_toTopOf="@+id/bottomNavigation" />

    <!-- Bottom Navigation -->
    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottomNavigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:menu="@menu/bottom_nav_menu"
        app:layout_constraintBottom_toBottomOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

8. Design Principles

  • Thumb Zone: Critical actions should be placed in the bottom third of the screen, making them accessible to a user holding a phone with one hand.
  • Visual Feedback: The selected tab or bottom nav item must be visually distinct (using color or filled icons) from the unselected items so the user always knows "where they are."

9. Common Mistakes

  • Putting too many items in Bottom Nav: Adding 6 or 7 items shrinks the touch targets, causing accidental clicks. Use 3 to 5 max.
  • Hiding Bottom Nav unnecessarily: While you can hide the bottom nav when scrolling down a list to save screen space, ensure it reappears immediately upon scrolling up.

10. Best Practices

  • Use outlined/hollow icons for unselected states and filled/solid icons for the selected state to create a strong visual cue.
  • Use BadgeDrawable to show notification dots (like unread message counts) on your Bottom Nav items.

11. Exercises

  1. 1. Modify a BottomNavigationView so that the text labels only appear on the currently active item.
  1. 2. Create a TabLayout with app:tabMode="scrollable" and add 8 dummy tabs to see how the horizontal scrolling behaves.

12. UI Design Challenges

Challenge: Design a "Floating Bottom Navigation". Instead of the navigation bar touching the very bottom and stretching edge-to-edge, use a MaterialCardView to create a pill-shaped navigation bar that "floats" 16dp above the bottom of the screen.

13. MCQ Quiz with Answers

Question 1

According to Material Design guidelines, what is the maximum recommended number of destinations in a Bottom Navigation bar?

Question 2

Which Android component is commonly paired with TabLayout to allow users to swipe left and right between tab contents?

14. Interview Questions

  • Q: What UX problems does Bottom Navigation solve compared to a Navigation Drawer?
  • Q: Explain the difference between primary navigation (Bottom Nav) and secondary navigation (Tabs).
  • Q: How would you display a badge with an unread count of "3" on a BottomNavigationView item?

15. Summary

In this chapter, we shifted our navigation paradigm to the bottom of the screen, embracing modern, ergonomic UI design. We learned how to configure and style a BottomNavigationView for major app sections, and how to utilize TabLayout paired with a ViewPager2 to effortlessly organize swipable sub-categories.

16. Next Chapter Recommendation

With our navigation architecture complete, it's time to gather information from the user. In Chapter 13: Designing Forms and Authentication Screens, we will dive into creating beautiful, user-friendly Login and Signup screens with polished input fields and validation states.

Finish this Chapter

Save your progress on your learning path and prepare for coding interview challenges.

Discussion

Join the discussion

Log in or create a free account to participate.

Sort: ·