How to use both Fragments and Child Fragments with Navigation Component?

Viewed 754

I'm making an app using the Navigation Component with Fragments as my individual destinations. I want to know how to implement a navigation flow like this:

enter image description here

In Destination 2, there's a menu button which can open a small menu(doesn't cover the entire screen). Inside the menu(Menu 1), there are other buttons clicking on which, the second menu(Menu 2) replaces the first one. Pressing the back button should move me as follows:

Destination 2(b) -> Destination 2(a) -> Destination 2 -> Destination 1

How do I go about implementing this with the Navigation Component? Just to be clear, the menus appear on top of Destination 2. So, content from both the menus and Destination 2 should be visible.

1 Answers

As far as I know this isn't possible with Navigation Component as it isn't it's intended use case. Navigation destinations should cover the full screen. For your menu1 and menu2 you should use a dialog/child fragment, and I think you'll need to handle back button presses manually.

Related