Bottom Navigation Demo in Android

By | June 15, 2017

To get started with this, you need the latest version (version 25) of Android SDK & tools (including SDK tools, build-tools, platform-tools, support repository).

Bottom Navigation Android


Add the design support library

First step is to add the design support library to your app-level build.gradle file. Example is as shown below:

dependencies {
    compile ''
	compile ''
	compile ''


Add the BottomNavigationView to your layout
Next step, is to add the actual bottom nav view to the layout. Typically, you will add something like:

       design:menu="@menu/bottom_nav_items" />

Whenever a new component is introduced, along with it some new methods and attributes are also added with it. Hence with the Android’s official bottom navigation widget the BottomNavigationView following new XML attributes are added:

  • – It is used to set the background color of the navigation item. It does not take a ColorStateList, as per design specifications.
  • – It is used to set the icon tint color, use a ColorStateList to specify colors for all states.
  • – It is used to set the text color of the navigation item, use a ColorStateList to specify colors for all states.

Navigation Items

Here we are going to set three bottom tabs.

To define the items, you need to do so in a menu resource. Let’s create one and name it bottom_nav_items.xml as we have specified in step 2 above.

<menu xmlns:android="">

        android:icon="@drawable/ic_notifications_black" />

Listening to Events

mBottomNav.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                // handle desired action here
                // One possibility of action is to replace the contents above the nav bar
                // return true if you want the item to be displayed as the selected item
                return true;


You can check the documentation from here

Source Code

You can download the complete source code from here

Leave a Reply

Your email address will not be published. Required fields are marked *