1/ Create A New Project and Use Material Bottom Navigation
<?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:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottomnav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#AEEBE9E9"
app:menu="@menu/bottom_nav" /> // It's bottom nav menu
</RelativeLayout>
2/ Create A Menu Directory inside drawable and get an XML
3/Get the Required items in this xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/home"
android:title="Home"
android:icon="@drawable/baseline_home_24"
/>
<item
android:id="@+id/list"
android:title="Home"
android:icon="@drawable/baseline_list_alt_24"
/>
<item
android:id="@+id/menu"
android:title="Home"
android:icon="@drawable/baseline_home_24"
/>
</menu>
4/ Go to java Activity
package com.example.bottomnavigation;
import android.os.Bundle;
import android.view.MenuItem;
import androidx.activity.EdgeToEdge;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.GravityCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.navigation.NavigationBarView;
public class MainActivity extends AppCompatActivity {
BottomNavigationView bottomnav;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bottomnav= findViewById(R.id.bottomnav);
bottomnav.setOnItemSelectedListener(new NavigationBarView.OnItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
if (item.getItemId()==R.id.home){
} else if (item.getItemId()==R.id.list) {
}else if (item.getItemId()==R.id.menu) {
}
return true;
}
});
}
}
5/ Now Run App and Output