https://kotlinlang.org logo
Title
n

Nikola Drljaca

12/12/2021, 6:33 PM
Anyone have an idea why
MaterialTransition
breaks when a
ComposeView
gets integrated into a Fragments XML layout? I have a few fragments using transitions and if I change a piece of the XML layout to use a ComposeView the transitions no longer run.
i

Ian Lake

12/12/2021, 6:45 PM
Did you set the right ViewCompositionStrategy on your ComposeView? https://developer.android.com/jetpack/compose/interop/interop-apis#composition-strategy
n

Nikola Drljaca

12/12/2021, 7:03 PM
I've tried the ones mentioned in the doc, though I have not tried to implement my own. The funny thing is I'm using the Navigation Component for fragments and when I set the enter/exit/popEnter/popExit animations, they work. But when I set exitTransitions/enterTrasitions etc. they don't work.
i

Ian Lake

12/12/2021, 8:18 PM
I'd make sure you are using the AndroidX Transitions versions of Material's transitions and make sure you add a dependency on the latest version of AndroidX Transitions - 1.4.1.
n

Nikola Drljaca

12/13/2021, 1:25 PM
So I've imported that library and switched from MaterialTransitions to AndroidX but still no dice. https://gist.github.com/nikolaDrljaca/75f3d078cdf25ae1358ba6b62c19892c Here's a link to a gist to see how the fragments look. I still feel like I'm missing something. I'm testing on a Pixel device, not sure if that has anything to do with it. Also, I haven't tried making a release build, though I feel like that shouldn't impact this.
Update for those who are interested. I managed to get the transitions working by adding
transitionName
to the
ComposeViews
and using
postponeEnterTransition()
with
ComposeView.doOnAttach{ startPostponedTransition() }