1

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?

Saikrishna Rajaraman
  • 3,205
  • 2
  • 16
  • 29
  • helpful link --> https://stackoverflow.com/questions/52437946/start-motion-scene-programmatically – Wini Jul 21 '20 at 13:54

3 Answers3

1

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)
Saikrishna Rajaraman
  • 3,205
  • 2
  • 16
  • 29
0

use transitionToEnd() method of MotionLayout

MJ Studio
  • 3,947
  • 1
  • 26
  • 37
0

Use the setProgress to 1f method did take effect ,but I can not receive the onTransitionCompleted event in TransitionListener

Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129
aLLLiyyy
  • 19
  • 1
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/31034925) – AndrewF Feb 16 '22 at 02:11