MotionLayout reference

MotionLayout uses a motion scene file to define a motion sequence. A motion scene file is an XML file that specifies all the aspects of a motion sequence. The <MotionLayout> node in the layout file has an app:layoutDescription attribute that points to the motion scene file.

This reference is not comprehensive. It provides information on the most important motion scene file elements and their most commonly used attributes.

<MotionScene>
The root element of a motion scene file.
<ConstraintSet>
Specifies the positions and attributes of all views at one point in a motion sequence.
<Constraint>
Specifies the location and attributes of one element of a motion sequence.
<Transition>
Specifies the beginning and end states of a motion sequence, the desired intermediate states, and the user interactions that trigger the sequence.
<OnClick>
Specifies the action to perform when the user taps a view.
<OnSwipe>
Specifies the action to perform when the user swipes on the layout.
<KeyFrameSet>
Specifies location and attributes for views over the course of the motion sequence.
<KeyPosition>
Specifies a view's location at a specific moment during the motion sequence.
<KeyAttribute>
Specifies a view's attributes at a specific moment during the motion sequence.