How to Implement Bottom Navigation With Activities in Android?
Last Updated :
18 Apr, 2025
We all have come across apps that have a Bottom Navigation Bar. Some popular examples include Instagram, WhatsApp, etc. Below is the preview of a sample Bottom Navigation Bar:

You must have seen the implementation of Bottom Navigation with the help of fragments. But, here we are going to implement Bottom Navigation with the help of activities in Android Studio.
What we are going to build in this application?
Here is a sample video of what we are going to build in this application. Note that we will be using Java language to make this application.
Step by Step Implementation
Step 1: Create a New Project
If you don’t know how to create a new project in Android Studio then you can refer to How to Create/Start a New Project in Android Studio?
Step 2: Working on XML files
Navigate to app > res > drawable, right-click, new > drawable resource file and name it as “selector“. Use the following code in selector.xml file-
XML
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_selected="true"
android:color="@color/white"/>
<item
android:state_selected="false"
android:color="@color/black"/>
</selector>
Navigate to app, right-click, new > android resource file of type menu and name it as “menu_navigation“. Use the following code in menu_navigation.xml file-
XML
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/dashboard"
android:title="Dashboard"
android:icon="@drawable/dashboard"/>
<item
android:id="@+id/home"
android:title="Home"
android:icon="@drawable/home"/>
<item
android:id="@+id/about"
android:title="About"
android:icon="@drawable/about"/>
</menu>
Step 3: Working with MainActivity files
MainActivity.java
package org.geeksforgeeks.demo;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import com.google.android.material.bottomnavigation.BottomNavigationView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Initialize and assign variable
BottomNavigationView bottomNavigationView=findViewById(R.id.bottom_navigation);
// Set Home selected
bottomNavigationView.setSelectedItemId(R.id.home);
// Perform item selected listener
bottomNavigationView.setOnItemSelectedListener(item -> {
int id = item.getItemId();
if (id == R.id.dashboard) {
startActivity(new Intent(getApplicationContext(), DashboardActivity.class));
overridePendingTransition(0, 0);
return true;
} else if (id == R.id.home) {
return true;
} else if (id == R.id.about) {
startActivity(new Intent(getApplicationContext(), AboutActivity.class));
overridePendingTransition(0, 0);
return true;
}
return false;
});
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Home"
android:textSize="50sp"
android:textStyle="bold"
android:layout_centerInParent="true"/>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
app:itemBackground="@color/colorPrimary"
app:itemIconTint="@drawable/selector"
app:itemTextColor="@drawable/selector"
app:menu="@menu/menu_navigation" />
</RelativeLayout>
Step 4: Create a new activity for Dashboard Screen
Navigate to the DashBoardActivity.java and it’s layout file and use the following code in it. Comments are added to the code to have a better understanding.
DashboardActivity.java
package org.geeksforgeeks.demo;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import com.google.android.material.bottomnavigation.BottomNavigationView;
public class DashboardActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dashboard);
// Initialize and assign variable
BottomNavigationView bottomNavigationView=findViewById(R.id.bottom_navigation);
// Set Home selected
bottomNavigationView.setSelectedItemId(R.id.dashboard);
// Perform item selected listener
bottomNavigationView.setOnItemSelectedListener(item -> {
int id = item.getItemId();
if (id == R.id.dashboard) {
return true;
} else if (id == R.id.home) {
startActivity(new Intent(getApplicationContext(),MainActivity.class));
overridePendingTransition(0,0);
return true;
} else if (id == R.id.about) {
startActivity(new Intent(getApplicationContext(), AboutActivity.class));
overridePendingTransition(0, 0);
return true;
}
return false;
});
}
}
activity_dashboard.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".DashboardActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dashboard"
android:textSize="50sp"
android:textStyle="bold"
android:layout_centerInParent="true"/>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
app:itemBackground="@color/teal_700"
app:itemIconTint="@drawable/selector"
app:itemTextColor="@drawable/selector"
app:menu="@menu/menu_navigation" />
</RelativeLayout>
Step 5: Create a new activity for About Screen
Navigate to the AboutActivity.java and it’s layout file and use the following code in it. Comments are added to the code to have a better understanding.
AboutActivity.java
package org.geeksforgeeks.demo;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import com.google.android.material.bottomnavigation.BottomNavigationView;
public class AboutActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
// Initialize and assign variable
BottomNavigationView bottomNavigationView=findViewById(R.id.bottom_navigation);
// Set Home selected
bottomNavigationView.setSelectedItemId(R.id.about);
// Perform item selected listener
bottomNavigationView.setOnItemSelectedListener(item -> {
int id = item.getItemId();
if (id == R.id.dashboard) {
startActivity(new Intent(getApplicationContext(), DashboardActivity.class));
overridePendingTransition(0, 0);
return true;
} else if (id == R.id.home) {
startActivity(new Intent(getApplicationContext(),MainActivity.class));
overridePendingTransition(0,0);
return true;
} else return id == R.id.about;
});
}
}
activity_about.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".AboutActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="About"
android:textSize="50sp"
android:textStyle="bold"
android:layout_centerInParent="true"/>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
app:itemBackground="@color/teal_700"
app:itemIconTint="@drawable/selector"
app:itemTextColor="@drawable/selector"
app:menu="@menu/menu_navigation" />
</RelativeLayout>
Output:
Similar Reads
Theming Floating Action Button with Bottom Navigation Bar in Android
In the previous article How to Add a Floating Action Button to Bottom Navigation Bar in Android?, it's well discussed how to add the Floating Action Button to the Bottom Navigation Bar in Android. Now to increase the UI/UX experience theming also can be done for the Bottom Navigation Bar. So in this
4 min read
Chip Bottom Navigation Bar in Android with Kotlin
We all know various apps that have a Bottom Navigation Bar. Some famous examples include Snapchat, Linkedin, Gmail, etc. In this article, letâs learn how to implement Chip Navigation Bottom Bar in Android apps using Kotlin. This Chip navigation is a mix of Bottom Navigation with Chip components. Als
3 min read
How to Implement MeowBottomNavigation in Andriod?
Meow Bottom Navigation in Android is simple & curved & material bottom navigation, it allows the user to switch to different activities/fragments easily with a beautiful animation in the bottom navigation. A sample video is given below to get an idea about what we are going to do in this art
2 min read
How to Implement Fancy Bottom NavigationBar in Flutter?
Fancy Bottom NavigationBar is a MaterialApp widget that displays a bottom fancy navbar, Where items go between 2 and 4. Bottom NavigationBar is the list of icons or text in the horizontal form called a tab and Each tab contains their own page. Step By Step ImplementationStep 1: Create a New Project
3 min read
How to Implement TabLayout with Icon in Android?
TabLayout is used to implement horizontal tabs. TabLayout is introduced in the design support library to implement tabs. Tabs are created using the newTab() method of TabLayout class. The title and icon of Tabs are set through setText(int) and setIcon(int) methods of TabListener interface respective
5 min read
How to Add a Floating Action Button to Bottom Navigation Bar in Android?
The floating action button is a bit different button from the ordinary buttons. Floating action buttons are implemented in the appâs UI for primary actions (promoted actions) for the users and the actions under the floating action button are prioritized by the developer. For example the actions like
3 min read
How to Implement Options Menu in Android?
In Android, there are three types of Menus available to define a set of options and actions in our android applications. Android Option Menus are the primary menus of android. They can be used for settings, searching, deleting items, etc. When and how this item should appear as an action item in the
4 min read
How to Implement ViewPager with Dotsindicator in Android?
ViewPager in Android is a class that allows the user to flip left and right through pages of data. This class provides the functionality to flip pages in-app. It is a widget found in the support library. What are Dotsindicator? These are dots that help us to see which view is currently opened when w
4 min read
Easy Stylish Chip Button in Bottom Navigation Bar in Android
We all have come across apps that have a Bottom Navigation Bar. Some popular examples include Instagram, Snapchat, etc. In this article, letâs learn how to implement an easy stylish functional Bottom Navigation Bar in the Android app. For Creating a Basic Bottom Navigation bar refer to Bottom Naviga
2 min read
How to Go Back to Previous Activity in Android?
In this article, we are going to see how we can add a back button to an activity through which we can go back to its previous activity. This can be achieved with just a few lines of code, which is explained in the steps below Step by Step ImplementationStep 1: Create a New Project in Android StudioT
3 min read