Getting started with
MotionLayout
Rebecca Franks
@riggaroo
Slide 2
Slide 2 text
What is MotionLayout?
• Subclass of ConstraintLayout
• With additional ways to animate views on screen
• For complex view animations driven by interactions
• Allows for midway seeking of animations
• Back-ported to API 14
Slide 3
Slide 3 text
Example usage
https://github.com/nikhilpanju/FabFilter
Slide 4
Slide 4 text
Get Started
Slide 5
Slide 5 text
Get Started
Include gradle dependency
dependencies {
implementation ‘androidx.constraintlayout:constraintlayout:2.0.0-beta4'
}
Slide 6
Slide 6 text
Change to use MotionLayout
Change usage of ConstraintLayout to MotionLayout
Link scene.xml to layout
Link the newly created motion_scene.xml to MotionLayout
Slide 9
Slide 9 text
Motion Scene
Slide 10
Slide 10 text
Motion Scene
• XML file that defines all animations for the scene
• Can be defined programmatically
• Contains: ConstraintSets, Transitions + KeyFrames
Slide 11
Slide 11 text
Components of Motion Scene
Slide 12
Slide 12 text
Constraint Sets / States
Different “resting” state that the Motion Scene will take
Slide 13
Slide 13 text
Transition
Defines the way in which two states will be transformed between.
- start / end state