Monday 28 September 2020

How to run multiple MaterialContainerTransform transitions simultaneously?

I'm trying to animate two sets of views simultaneously using the MaterialContainerTransform transition. However, with the code below, only the first transition runs correctly, while the second jumps from the start to the end state unanimated. When tested separately, both run as they should. After searching the internet for many hours, I have so far been unable to find any solution to this. Any help would be appreciated!

val transform = TransitionSet().apply {
    ordering = TransitionSet.ORDERING_TOGETHER

    addTransition(MaterialContainerTransform().apply {
        startView = startViewA
        endView = endViewA

        addTarget(endViewA)

        pathMotion = MaterialArcMotion()
        scrimColor = Color.TRANSPARENT
    })

    addTransition(MaterialContainerTransform().apply {
        startView = startViewB
        endView = endViewB

        addTarget(endViewB)

        pathMotion = MaterialArcMotion()
        scrimColor = Color.TRANSPARENT
    })
}

TransitionManager.beginDelayedTransition(viewContainer, transform)

startViewA?.visibility = View.GONE
endViewA?.visibility = View.VISIBLE
endViewB?.visibility = View.INVISIBLE
startViewB?.visibility = View.VISIBLE


from How to run multiple MaterialContainerTransform transitions simultaneously?

No comments:

Post a Comment