11

Is it possible to share navigation graph between two (or more) containers? What I would like to achieve is to have two containers (NavHosts):

  • one smaller that is above bottom navigation and below toolbar
  • second is full screen.

I would like to have one navigation graph, because fragments from one container can trigger actions from other one. Otherwise it (having more navigation graphs that interacts with each other) will become untidy and problems created by library will surpass advantages.

ianhanniballake
  • 191,609
  • 30
  • 470
  • 443

2 Answers2

1

Seems like you cannot, however you can have nested navigation: i.e. wrap your toolbar navigation inside of fullscreen (of vice versa) and playing with navController.popBackStack(<id of nested item>)

Dmitry Valetin
  • 375
  • 2
  • 6
  • Thanks, but I am not interested in dealing with visibility of navigation views based on currently displayed fragment. For now I've decided to abandon navigation component library. – Wiktor Wardzichowski Jun 30 '18 at 13:43
0

Yes, it is possible. Take a look at this sample. This is an implementation of Android Navigation component with bottom navigation view with separate history for each tab. You can use the concept and change it the way that fits your app

moallemi
  • 2,448
  • 2
  • 25
  • 28