Search code examples
androidandroid-fragmentsandroid-architecture-componentsandroid-jetpackandroid-architecture-navigation

How to navigate to Half Fragment ? (Navigation Architecture Component)


I am trying Navigation architecture Component in My app. Earlier i Used Fragment Transaction's to achieve the below feature. Basically i want to navigate from.

FragmentA->FragmentB (custom fragment partially transparent and half of screen size)

If i am using Navigation component and try

Navigation.findNavController(view).navigate(R.id.action_FragmentA_to_FragmentB)

Then the result is the FragmentA is replaced by FragmentB and the background fragment is not visible.

I want to know of a solution if it's allowed by Navigation Architecture Component.

P.S: I have heard about nested Navigation Host,But is it good to use from inside Fragment.

Update:

The FragmentB will have action's for further transaction's and example:

FragmentA->FragmentB->FragmentC (custom fragment partially transparent and half of screen size)

And Fragment C should replace FragmentB when user press back button and backStack should be maintained for all the fragment transactions.

Demo


Solution

  • TLDR:I used nested graphs for achieving the requirement.

    Hello, thanks for help but navigating in BottomSheet is achieved by me using below procedure.

    • MainActivity

      • NavHost(FragXYZ->FragA)
        • (Inside Fragment A)BottomSheetDialogFragment.show() to display the bottomSheetMenu
          • (Inside Fragment B) BottomSheetDialogChildFragment(start child Fragment of BottomSheetDialogFragment using Fragment Transaction) extends NavHostFragment

    Demo:GitHub