- Add Navigation Architecture Component & Material Design Dependencies
//navigation architecture component
implementation “androidx.navigation:navigation-fragment-ktx:2.3.0”
implementation “androidx.navigation:navigation-ui-ktx:2.3.0”// material design
implementation ‘com.google.android.material:material:1.2.0’
2. Create Menu Resource for Bottom Navigation View (res/menu/menu_bottom_sheet_main.xml)
<?xml version=”1.0" encoding=”utf-8"?>
<menu xmlns:android=”http://schemas.android.com/apk/res/android" <item
android:id=”@+id/nav_personal”
android:icon=”@drawable/ic_personal”
android:title=”Personal” /> <item
android:id=”@+id/nav_transaction”
android:icon=”@drawable/ic_transaction”
android:title=”Transaction” /> <item
android:id=”@+id/nav_promotional”
android:icon=”@drawable/ic_promotional”
android:title=”Promotional” /> <item
android:id=”@+id/nav_blocked”
android:icon=”@drawable/ic_blocked”
android:title=”Blocked” />
</menu>
3. Add BottomNavigationView to Activity XML (activity_main.xml)
<?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"
xmlns:tools=”http://schemas.android.com/tools"
android:layout_width=”match_parent”
android:layout_height=”match_parent”
tools:context=”.MainActivity”> <com.google.android.material.bottomnavigation.BottomNavigationView
android:id=”@+id/main_bottom_navigation_view”
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
app:labelVisibilityMode=”labeled”
app:layout_constraintBottom_toBottomOf=”parent”
app:layout_constraintEnd_toEndOf=”parent”
app:layout_constraintStart_toStartOf=”parent”
app:menu=”@menu/menu_bottom_sheet_main” />
</androidx.constraintlayout.widget.ConstraintLayout>