{"id":3811,"date":"2020-05-10T15:55:19","date_gmt":"2020-05-10T05:55:19","guid":{"rendered":"https:\/\/learntodroid.com\/?p=3811"},"modified":"2020-09-20T11:56:59","modified_gmt":"2020-09-20T01:56:59","slug":"how-to-use-the-jetpack-navigation-component-with-bottom-navigation","status":"publish","type":"post","link":"http:\/\/10.0.0.14:32769\/how-to-use-the-jetpack-navigation-component-with-bottom-navigation\/","title":{"rendered":"How to Use the Jetpack Navigation Component with Bottom Navigation"},"content":{"rendered":"\n

Bars containing icons and text that run along the bottom of the screen are common when implementing navigation in an Android app. This kind of navigation can be achieved using the Android material design widget BottomNavigationView.<\/p>\n\n\n\n

The Jetpack navigation architecture component simplifies the process of implementing navigation within your Android app and can be used with the BottomNavigationView widget.<\/p>\n\n\n\n

To use the Jetpack navigation architecture component with bottom navigation you will need to do the following.<\/strong><\/p>\n\n\n\n

  1. Retrieve the Jetpack navigation component dependencies using Gradle<\/strong><\/li>
  2. Create the String and Drawable Resources to use as Icons and Labels<\/strong><\/li>
  3. Create the Menu Resource for the BottomNavigationView <\/strong><\/li>
  4. Add the BottomNavigationView to the Activity Layout Resource<\/strong><\/li>
  5. Create the Navigation Graph<\/strong><\/li>
  6. Add the NavHostFragment to the Activity Layout Resource<\/strong><\/li>
  7. Add the Fragments as Destinations to the Navigation Graph<\/strong><\/li>
  8. Setup the NavController with the BottomNavigationView in the Activity class<\/strong><\/li><\/ol>\n\n\n\n

    I have written this tutorial that goes into greater details on these steps on how to setup the Jetpack navigation component with the BottomNavigationView widget to enable bottom navigation within your Android app.<\/p>\n\n\n\n

    I have also included code samples which are available in a public code repository in GitHub at the link below.<\/p>\n\n\n\n

    https:\/\/github.com\/learntodroid\/BottomNavigationTutorial<\/a><\/p>\n\n\n\n

    I have created a video tutorial on this blog post which I have uploaded to YouTube which I have embedded below.<\/p>\n\n\n\n

    \n
    https:\/\/www.youtube.com\/watch?v=qF4trCKJd1k<\/a>