Step 1 main.xml


<androidx.drawerlayout.widget.DrawerLayout 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/drawer_layout"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:fitsSystemWindows="true"

    tools:openDrawer="start">


    <include

        layout="@layout/app_bar_main"

        android:layout_width="match_parent"

        android:layout_height="match_parent" />


    <androidx.constraintlayout.widget.ConstraintLayout

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        android:orientation="vertical">


        <FrameLayout

            android:id="@+id/fragment_container"

            android:layout_width="match_parent"

            android:layout_height="match_parent"

            android:layout_marginTop="?android:actionBarSize"

            app:layout_constraintLeft_toLeftOf="parent"

            app:layout_constraintTop_toTopOf="parent" />


        <nl.joery.animatedbottombar.AnimatedBottomBar

            android:id="@+id/navigation"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:background="@drawable/bg_half_rounded"

            android:elevation="5dp"

            app:abb_animationDuration="500"

            app:abb_animationInterpolator="@android:anim/overshoot_interpolator"

            app:abb_indicatorAppearance="round"

            app:abb_indicatorColor="@color/white"

            app:abb_indicatorHeight="5dp"

            app:abb_indicatorMargin="30dp"

            app:abb_selectedIndex="1"

            app:abb_selectedTabType="text"

            app:abb_tabAnimation="slide"

            app:abb_tabColor="@color/white"

            app:abb_tabColorSelected="@color/white"

            app:abb_tabs="@menu/navigation"

            app:layout_constraintBottom_toBottomOf="parent"

            app:layout_constraintLeft_toLeftOf="parent"

            app:layout_constraintRight_toRightOf="parent"

            tools:ignore="MissingConstraints" />


    </androidx.constraintlayout.widget.ConstraintLayout>


    <com.google.android.material.navigation.NavigationView

        android:id="@+id/nav_view"

        android:layout_width="wrap_content"

        android:layout_height="match_parent"

        android:layout_gravity="start"

        android:background="@color/teal"

        android:fitsSystemWindows="true"

        android:paddingEnd="15dp"

        app:headerLayout="@layout/nav_header_main"

        app:itemBackground="@drawable/drawer_selected_item"

        app:itemIconTint="@color/drawer_item_color"

        app:itemTextColor="@color/drawer_item_color"

        app:labelVisibilityMode="labeled"

        app:menu="@menu/menu_navigation_drawer"

        tools:ignore="RtlSymmetry">


        <RelativeLayout

            android:layout_width="match_parent"

            android:layout_height="match_parent">


            <TextView

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:layout_alignParentBottom="true"

                android:layout_marginBottom="10dp"

                android:gravity="center_horizontal"

                android:text="@string/version_app"

                android:textColor="@color/white"

                android:textSize="14sp" />

        </RelativeLayout>

    </com.google.android.material.navigation.NavigationView>

</androidx.drawerlayout.widget.DrawerLayout>


Step 2 Main.java

package in.learncodewithrk.vegetablesappui;


import android.annotation.SuppressLint;

import android.os.Bundle;

import android.util.Log;

import android.view.MenuItem;

import android.widget.Toast;


import androidx.annotation.NonNull;

import androidx.appcompat.app.ActionBarDrawerToggle;

import androidx.appcompat.app.AppCompatActivity;

import androidx.appcompat.widget.Toolbar;

import androidx.core.view.GravityCompat;

import androidx.drawerlayout.widget.DrawerLayout;

import androidx.fragment.app.Fragment;

import androidx.fragment.app.FragmentManager;


import com.google.android.material.navigation.NavigationView;



import java.util.Objects;


import nl.joery.animatedbottombar.AnimatedBottomBar;


public class MainActivity extends AppCompatActivity {

    private static final String TAG = MainActivity.class.getSimpleName();

    private Toolbar toolbar;

    AnimatedBottomBar animatedBottomBar;

    FragmentManager fragmentManager;


    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);


        setToolbar();

        initViews(savedInstanceState);

        initComponentsNavHeader();

    }


    private void setToolbar() {

        toolbar = findViewById(R.id.toolbar);

        setSupportActionBar(toolbar);

        Objects.requireNonNull(getSupportActionBar()).setTitle(0);

    }


    @SuppressLint("NonConstantResourceId")

    private void initViews(Bundle savedInstanceState) {

        /**

         * Menu Bottom Navigation Drawer

         * */

        animatedBottomBar = findViewById(R.id.navigation);


        if (savedInstanceState == null) {

            animatedBottomBar.selectTabById(R.id.nav_menu_home, true);

            fragmentManager = getSupportFragmentManager();

            HomeFragment homeFragment = new HomeFragment();

            fragmentManager.beginTransaction().replace(R.id.fragment_container, homeFragment)

                    .commit();

        }


        animatedBottomBar.setOnTabSelectListener((lastIndex, lastTab, newIndex, newTab) -> {

            Fragment fragment = null;

            switch (newTab.getId()) {

                case R.id.nav_menu_home:

                    fragment = new HomeFragment();

                    break;

                case R.id.nav_menu_wishlist:

                    fragment = new FavoriteFragment();

                    break;

                case R.id.nav_menu_signin:

                    fragment = new ProfileFragment();

                    break;

            }


            if (fragment != null) {

                fragmentManager = getSupportFragmentManager();

                fragmentManager.beginTransaction().replace(R.id.fragment_container, fragment)

                        .commit();

            } else {

                Log.e(TAG, "Error in creating Fragment");

            }

        });


        /**

         * Menu Navigation Drawer

         **/

        DrawerLayout drawer = findViewById(R.id.drawer_layout);

        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(

                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);

        drawer.addDrawerListener(toggle);

        toggle.setDrawerIndicatorEnabled(false);

        toggle.setToolbarNavigationClickListener(view -> drawer.openDrawer(GravityCompat.START));

        toggle.setHomeAsUpIndicator(R.drawable.ic_drawer);

        toggle.syncState();

    }


    private void initComponentsNavHeader(){

        NavigationView navigationView = findViewById(R.id.nav_view);

//        navigationView.setItemIconTintList(null); //disable tint on each icon to use color icon svg

        navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {

            @SuppressLint("NonConstantResourceId")

            @Override

            public boolean onNavigationItemSelected(@NonNull MenuItem item) {

                switch (item.getItemId()) {

                    case R.id.nav_weeds:

                        Pesan("Menu Weeds");

                        break;

                    case R.id.nav_insects:

                        Pesan("Menu Insects");

                        break;

                    case R.id.nav_diseases:

                        Pesan("Menu Diseases");

                        break;

                    case R.id.nav_products:

                        Pesan("Menu Products");

                        break;

                    case R.id.nav_help:

                        Pesan("Menu Help");

                        break;

                }


                DrawerLayout drawer = findViewById(R.id.drawer_layout);

                drawer.closeDrawer(GravityCompat.START);

                return true;

            }


            private void Pesan(String pesan) {

                Toast.makeText(MainActivity.this, pesan, Toast.LENGTH_SHORT).show();

            }

        });

    }


    @Override

    public void onBackPressed() {

        DrawerLayout drawer = findViewById(R.id.drawer_layout);

        if (drawer.isDrawerOpen(GravityCompat.START)) {

            drawer.closeDrawer(GravityCompat.START);

        } else {

            super.onBackPressed();

        }

    }

}


SOURCE : https://user-images.githubusercontent.com/71060268/134866578-9628ca8d-eded-47a3-b30a-d5f055798d9d.png

GITHUB : https://github.com/LearncodeWithRk/Navigation-Drawer-With-Bottom-Navigation-View-