MrVasilev
MrVasilev

Reputation: 1563

Android Architecture navigation Component with Bottom Navigation?

Now I am wondering which is the most proper way of implementation when want to combine BottomNavigation with the new Android Architecture Navigation Component?

For now found two approaches:

  1. Single Navigation Graph which maintains all BottomNavigation items and which is shown here from Google Codelabs: https://codelabs.developers.google.com/codelabs/android-navigation/#1
  2. Multiple Navigation Graphs where every BottomNavigation item has its own navigation graph which maintains only its behavior and backstack which i shown here: https://proandroiddev.com/mastering-the-bottom-navigation-with-the-new-navigation-architecture-component-cd6a71b266ae

My opinion is that the second one is more clear and understandable, but maybe you have another opinion.

Upvotes: 20

Views: 12241

Answers (2)

Bilal Aslam
Bilal Aslam

Reputation: 839

Having separate backstacks or not is a decision based on user experience but if you do want multiple backstacks for bottomnavigation then follow the link for correct approach by androidx developers. https://github.com/googlesamples/android-architecture-components/tree/master/NavigationAdvancedSample

Upvotes: 9

Melvin Otieno
Melvin Otieno

Reputation: 79

I think it depends with the number of nested fragments you will have per each navigation item. The fewer the fragments then i would use the first approach and the more the fragments then i would use the latter approach

Upvotes: 0

Related Questions