Picture from Vlad Chețan on Pexels

Navigation Component, Bottom Navigation, and how to make them behave

I have been programming on Android for a while, and the only part of Jetpack I could never fit in any project was the Navigation component. Implementing it in an existing architecture looked like a lot of work that could be postponed (shame on me!), and I’ve never had a project that it quite fit into.

The scenario

This time around, I wanted to get a first-hand experience with many of the technologies I never get to use in a new project, a small app that will guide me through my diet. The UI that I have in mind requires a BottomNavigationView that will be linked to two Fragments.

Wiring the Navigation component

Once we have our View setup, we can link each Fragment to the related entry. As the first step, we should create an XML file in the navigation folder of the app’s resources: let’s call it mobile_navigation.xml.


Once all these steps have been performed, no more code is needed to navigate using the BottomNavigationView, and the only changes needed if we want to change the entries would be in the menu file, and in mobile_navigation.xml.

Android developer and GDE for Android

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store