Reputation: 3273
There is an option to jump to end ConstraintSet
in XML in MotionLayout
.
<Transition
app:autoTransition="jumpToEnd"
motion:constraintSetEnd="@+id/constraintStart"
motion:constraintSetStart="@+id/constraintEnd"
motion:duration="300" />
Can this be done programmatically?
Upvotes: 1
Views: 1871
Reputation: 19
Use the setProgress to 1f method did take effect ,but I can not receive the onTransitionCompleted event in TransitionListener
Upvotes: 0
Reputation: 3273
I figured it out. In order to jump to a ConstraintSet
set the progress of MotionLayout
to 1.
motionLayout?.setProgress(1.0f)
When you have multiple transitions, then set the state of MotionLayout
to final ConstraintSet
and then set the progress to 1.
motionLayout?.setState(R.id.endConstraintSet,ConstraintSet.MATCH_CONSTRAINT,ConstraintSet.MATCH_CONSTRAINT)
motionLayout?.setProgress(1.0f)
Upvotes: 1