I have a MotionScene with 4 ConstraintSets representing 4 states of screen (loading states) and with 3 Transitions between them. When my app state changes from e.g. loading to processing, I want to run Transition 1 (set1 -> set2), when state changes again, I want to run Transition 2 (set2 -> set3). And I can't find a way to do it.
I tried next:
To set current transition with
motion_layout.setTransition(R.id.set1, R.id.set2)
motion_layout.transitionToState(R.id.set2)
To just set transition
motion_layout.setTransition(R.id.set1)
To transition to some state:
motion_layout.transitionToState(R.id.set1)
but all of the above methods run all my sets together, even if I use app:autoTransition="none" .
I tried to put everything in one Transition and set app:progress = 0 on , and then control state of animation with progress:
motion_layout.setProgress(0.25f, 1.0f)
which just runs all animation to the end, or I tried
motion_layout.progress = 0.25f
which don't animate, it just shows me 0.25 progress of animation without any motion.
How to control the flow of animation? How to run particular set? Would it be better to use progress? How to solve it?
P.S. I use
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta7'
MotionLayout bridges the gap between layout transitions and complex motion handling, offering a mix of features between the property animation framework, TransitionManager , and CoordinatorLayout . In addition to describing transitions between layouts, MotionLayout lets you animate any layout properties, as well.
Unless you have it should only transition to the state you call if you call ml.transitionToState(R.id.xx);
Remove all autoTransition attributes in you motionScene
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With