ConstraintLayout: Animate multiple ConstraintSet sequentially

Viewed 393

I have n layouts that represent n different keyframes of an animation. I would like to be able to play this animation sequentially: from layout 1 to layout 2, from layout 2 to layout 3 and so on.

Currently I am able to run the first frame change of the animation with this code:

val constraintSet = ConstraintSet()
constraintSet.clone(this@DemoUiActivity, R.layout.animation_keyframe_2)

val transition = ChangeBounds()
transition.interpolator = AnticipateOvershootInterpolator(1.0f)
transition.duration = 1000

TransitionManager.beginDelayedTransition(binding.animationContainer.root as ConstraintLayout, transition)
constraintSet.applyTo(binding.animationContainer.root as ConstraintLayout)

where the layout animation_keyframe_1 is included in the default layout of the Activity.

I would like to find a way to run in sequence multiple layout changes, without having to use a Transition listener to manually run specify which keyframe has to be animated next.

Is there a way to specify a list of layout changes and play them sequentially?

0 Answers
Related