'Circular reveal animation in new Navigation architecture

I am able to go to my next destination with a circular reveal animation. My only problem is the previous fragment is gone, unless I set a fade out exit transition in my action app:exitAnim="@anim/exit_fade_out". I wanted to ask if anyone has been able to keep the previous fragment visible while doing the circular revealing.

this is the code for revealing and hiding the new fragment.. so far this works yet I cannot show the previous fragment as its masking the next one

private val maxScreenDimension : Float
get() {
    return max(container.width, container.height).toFloat()
}

private fun circularReveal(point: Point) {
    val viewTreeObserver = container.viewTreeObserver
    if (viewTreeObserver.isAlive) {
        viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
            override fun onGlobalLayout() {
                doCircularReveal(point)
                container.viewTreeObserver.removeOnGlobalLayoutListener(this)
            }
        })
    }
}

private fun doCircularReveal(point: Point) {
    val initRadius = 0f
    val finalRadius = maxScreenDimension

    val circularReveal = ViewAnimationUtils.createCircularReveal(
        container,
        point.x,
        point.y,
        initRadius,
        finalRadius
    )

    circularReveal.duration = resources.getInteger(R.integer.circular_animation_out).toLong()

    circularReveal.start()
}

private fun circularHide(point: Point) {
    val initRadius = maxScreenDimension
    val finalRadius = 0f

    val circularReveal = ViewAnimationUtils.createCircularReveal(
        container,
        point.x,
        point.y,
        initRadius,
        finalRadius
    )

    circularReveal.duration = resources.getInteger(R.integer.circular_animation_in).toLong()
    circularReveal.doOnEnd {
        container.isVisible = false
        findNavController().popBackStack()
    }

    circularReveal.start()
}


Solution 1:[1]

So in case you wonder how to retain the previous screen and do a circular reveal animation for the next screen. My solution was to simply add a new fragment. I don't think the Navigation component allows for this type of animation. Earlier I did a shared element transition which worked fine as long as I used a fade in/out transition between the two screens. In that way I was able to retain the previous screen while the shared element transition played out. I am thinking the Navigation component is constantly replacing the following fragment.

Solution 2:[2]

You can do a little hack to make Navigation component to leave the fragment in place during circular reveal animation by giving it a fake animation for exitAnim with the same duration that your circular reveal. For example it can look like this:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <alpha android:fromAlpha="1.0" android:toAlpha="1.0"
        android:duration="@android:integer/config_mediumAnimTime" />
</set>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Juan Mendez
Solution 2 Andranik