Bogdan Zurac
Bogdan Zurac

Reputation: 6451

FragmentNavigator add Fragment instead of replace for transparent background

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?

Upvotes: 12

Views: 1550

Answers (1)

musooff
musooff

Reputation: 6872

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.

Upvotes: 1

Related Questions