I have the following situation. Activity[FragmentWithPager[PageWithGrid]]and I want to do trandition animation from list itemto DetailFragment, but I don't know if I will be wrong. I said the same transitionNameto the representations in models list itemand fragment detailtry to do animatiot transition to the following code.
val fragmentTransaction = supportFragmentManager.beginTransaction()
transitionItems.forEach { view ->
fragmentTransaction.addSharedElement(view, view.transitionName)
}
val fragment = DetailFragment()
val transitionSet = TransitionSet().apply {
addTransition(ChangeTransform())
addTransition(ChangeClipBounds())
addTransition(ChangeBounds())
}
fragment.sharedElementEnterTransition = transitionSet
fragment.sharedElementReturnTransition = transitionSet
fragmentTransaction.replace(R.id.root, fragment)
fragmentTransaction.addToBackStack(null)
fragmentTransaction.commit()
source
share