11

When using the Navigation library from AndroidX, I'd like to display a Fragment with a semi-transparent background on top of the old destination. So basically, instead of the FragmentNavigator doing ft.replace(mContainerId, frag) inside its navigate() method, having a ft.add(mContainerId, frag) instead.

I've tried subclassing FragmentNavigator, but the API is very strongly limited (lots of private variables and package protected methods), thus not being able to properly override the navigate() method in order to make that change.

So, what would be the correct method to achieve support for Fragments with transparent background using the Navigation library?

Bogdan Zurac
  • 6,348
  • 11
  • 48
  • 96
  • 2
    Did you find a way to solve this problem? @ianhanniballake please can you take a look to this post? – JavierSegoviaCordoba Apr 08 '19 at 22:51
  • 4
    I already pinged Ian on this one. He said support for DialogFragments is coming soon. Currently I just have another FrameLayout on the same level as the NavController in the root Activity and manually add the Fragment with the transparent background to it, then manually remove it on back pressed. It's not nice, but gets the job done – Bogdan Zurac Apr 09 '19 at 04:19
  • 1
    Can you guide me how to subclass FragmentNavigator ? I can't seem to understand what to do after extending it. – Syed Ahmed Jamil Dec 12 '19 at 00:41

1 Answers1

1

If what you are looking for is Dialog, then it is now fully supported as of 2.1.0-alpha03

You can achieve your intended behavior with dialog destination which will show on top of your current destination.

musooff
  • 6,412
  • 3
  • 36
  • 65