widget animation in your app. • Subclass of ConstraintLayout and builds upon its rich layout capabilities. • Available as a support library and is backwards-compatible to API level 14. What is Motion Layout?
xml layout to motion layout <androidx.constraintlayout.motion.widget.MotionLayout/> • Link layout to motion scene file <androidx.constraintlayout.motion.widget.MotionLayout . app:layoutDescription="@xml/activity_main_scene" > Getting started:
that the motion scene will take. • Define the constraints that define your motion. <MotionScene..> <ConstraintSet android:id="@+id/start"> <Constraint android:layout_height="wrap_content" motion:layout_constraintTop_toTopOf="parent" motion:layout_constraintLeft_toLeftOf="parent" motion:layout_constraintRight_toRightOf="parent" android:layout_width="wrap_content" android:id="@+id/textView"/> </ConstraintSet> </MotionScene>
will be transformed <MotionScene..> <Transition motion:constraintSetEnd="@+id/end" motion:motionInterpolator="linear" motion:constraintSetStart="@id/start" motion:duration="1000"/> </MotionScene>
transition where we can change any attribute. • Helps one modify the path the view takes during animations <MotionScene..> <KeyFrameSet> <KeyAttribute motion:motionTarget="@+id/textView" motion:framePosition="50" android:scaleX="2.0" /> <KeyAttribute motion:motionTarget="@+id/textView" motion:framePosition="50" android:scaleY="2.0" /> </KeyFrameSet> </MotionScene>