Start motion scene programmatically

后端 未结 5 956
心在旅途
心在旅途 2020-12-30 21:12

I have a motion layout with this layoutDescription: app:layoutDescription=\"@xml/scene\"

scene.xml



        
5条回答
  •  Happy的楠姐
    2020-12-30 21:25

    If anyone's doing this from a fragment:

    1. Import:

      import androidx.constraintlayout.motion.widget.MotionLayout;
      
    2. Instantiate MotionLayout:

      MotionLayout motionLayout = view.findViewById(R.id.your_motion_layout);
      
    3. Transition to the end/start of motion:

      motionLayout.transitionToStart();
      

    or

        motionLayout.transitionToEnd();
    

提交回复
热议问题