Start motion scene programmatically
If anyone's doing this from a fragment:
Import:
import androidx.constraintlayout.motion.widget.MotionLayout;
Instantiate MotionLayout:
MotionLayout motionLayout = view.findViewById(R.id.your_motion_layout);
Transition to the end/start of motion:
motionLayout.transitionToStart();
or
motionLayout.transitionToEnd();
You can also do this in your xml with
motion:autoTransition="animateToEnd"
and
motion:autoTransition="animateToStart"
Finally Im doing this:
((MotionLayout)findViewById(R.id.motionLayout)).transitionToEnd();
((MotionLayout)findViewById(R.id.motionLayout)).transitionToStart();