SlideShare a Scribd company logo
1 of 139
Download to read offline
Deep dive into
MotionLayout
John Hoford
@johnhoford
Nicolas Roard
@camaelon
Takeshi Hagikura
@thagikura
ConstraintLayout 2.0
DroidKaigi 2019
ConstraintLayout 2.0
• Helpers, Virtual Layouts, MotionLayout

• Announced at Google IO’18

• Built upon ConstraintLayout 1.1

• currently : alpha 3

• alpha 4 in a few weeks (?)
ConstraintSet
Encapsulate all the rules for a layout

Apply ConstraintSet to an existing layout

Switch between multiple ConstraintSets

Basic animation capabilities using TransitionManager
Droidkaigi 2019
Documentation
• Medium Articles:

• Introduction to MotionLayout part I http://bit.ly/2O4AmIz

• Introduction to MotionLayout part II http://bit.ly/2uPuWbw

• Introduction to MotionLayout part III http://bit.ly/2zRjCSj

• Introduction to MotionLayout part IV http://bit.ly/2QqfJaF

• GitHub:

• https://github.com/googlesamples/android-ConstraintLayoutExamples
Motion Layout Basic Example
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.motion.MotionLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/motionLayout"
app:layoutDescription=“@xml/scene"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/button"
android:background="@color/colorAccent"
android:layout_width="64dp"
android:layout_height="64dp"/>
</android.support.constraint.motion.MotionLayout>
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.motion.MotionLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/motionLayout"
app:layoutDescription=“@xml/scene"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/button"
android:background="@color/colorAccent"
android:layout_width="64dp"
android:layout_height="64dp"/>
</android.support.constraint.motion.MotionLayout>
<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">
<Transition
motion:constraintSetStart="@+id/start"
motion:constraintSetEnd="@+id/end"
motion:duration="1000">
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@+id/button"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginStart="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent" />
<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">
<Transition
motion:constraintSetStart="@+id/start"
motion:constraintSetEnd="@+id/end"
motion:duration="1000">
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@+id/button"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginStart="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent" />
motion:constraintSetStart="@+id/start"
motion:constraintSetEnd="@+id/end"
motion:duration="1000">
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@+id/button"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginStart="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent" />
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@+id/button"
android:layout_width="64dp"
android:layout_marginStart="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent" />
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@+id/button"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginEnd="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintTop_toTopOf="parent" />
</ConstraintSet>
</MotionScene>
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.motion.MotionLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/motionLayout"
app:layoutDescription=“@xml/scene"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/button"
android:background="@color/colorAccent"
android:layout_width="64dp"
android:layout_height="64dp"/>
</android.support.constraint.motion.MotionLayout>
android:layout_height="match_parent">
<View
android:id="@+id/button"
android:background="@color/colorAccent"
android:layout_width="64dp"
android:layout_height=“64dp"/>
</android.support.constraint.motion.MotionLayout>
android:layout_height="match_parent">
<View
android:id="@+id/button"
android:background="@color/colorAccent"
android:layout_width="64dp"
android:layout_height=“64dp"/>
</android.support.constraint.motion.MotionLayout>
<Button
android:id=“@+id/run"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:text="Run"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
class BasicTransitionActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.motion)
run.setOnClickListener {
motionLayout.transitionToEnd()
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">
<Transition
motion:constraintSetStart="@+id/start"
motion:constraintSetEnd="@+id/end"
motion:duration="1000">
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@+id/button"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginStart="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent" />
<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">
<Transition
motion:constraintSetStart="@+id/start"
motion:constraintSetEnd="@+id/end"
motion:duration="1000">
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@+id/button"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginStart="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">
<Transition
motion:constraintSetStart="@+id/start"
motion:constraintSetEnd="@+id/end"
motion:duration="1000">
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@+id/button"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginStart="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
<OnClick
motion:target=“@id/run"/>
xmlns:motion="http://schemas.android.com/apk/res-auto">
<Transition
motion:constraintSetStart="@+id/start"
motion:constraintSetEnd="@+id/end"
motion:duration="1000">
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@+id/button"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginStart="8dp"
xmlns:motion="http://schemas.android.com/apk/res-auto">
<Transition
motion:constraintSetStart="@+id/start"
motion:constraintSetEnd="@+id/end"
motion:duration="1000">
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@+id/button"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginStart="8dp"
<OnSwipe
motion:dragDirection="dragRight"
motion:touchAnchorId="@id/button"
motion:touchAnchorSide="right" />
Motion Layout Components
MotionLayout
MotionScene
layout/motion.xml
MotionLayout
View
Helpers
View
Helpers
layout/motion.xml
MotionLayout
View
Helpers
View
Helpers
layout_description=“@xml/scene
xml/scene.xml
MotionScene
layout/motion.xml
MotionLayout
View
Helpers
View
Helpers
layout_description=“@xml/scene
xml/scene.xml
MotionScene
ConstraintSet
ConstraintSet
layout/motion.xml
MotionLayout
View
Helpers
View
ConstraintView
Helpers
View
Constraint
layout_description=“@xml/scene
ConstraintSets
ConstraintSet
★ Encapsulate all the rules for a layout
★ Switch between multiple ConstraintSets
xml/
motion_scene.xml
MotionScene
ConstraintSet
ConstraintSet
View
Constraint
xml/
motion_scene.xml
MotionScene
ConstraintSet
ConstraintSet
View
Constraint
<MotionScene>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@id/button"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginStart="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent">
</Constraint>
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@id/button"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginEnd="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintTop_toTopOf="parent">
</Constraint>
</ConstraintSet>
</MotionScene>
xml/
motion_scene.xml
MotionScene
ConstraintSet
ConstraintSet
View
Constraint
<MotionScene>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@id/button"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginStart="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent">
</Constraint>
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@id/button"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginEnd="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintTop_toTopOf="parent">
</Constraint>
</ConstraintSet>
</MotionScene>
xml/
motion_scene.xml
MotionScene
ConstraintSet
ConstraintSet
View
Constraint
<MotionScene>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@id/button"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginStart="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent">
</Constraint>
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@id/button"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginEnd="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintTop_toTopOf="parent">
</Constraint>
</ConstraintSet>
</MotionScene>
Interpolated Attributes
• Position, Dimensions

• Visibility & Alpha

• Translation, Rotation, Scale, Elevation

• Custom attributes
Custom Attributes
• Extension to ConstraintSet

• Define values for any attribute

• Specify the type

• Specify the setter name
string
color
integer
float
dimension
boolean
xml/
motion_scene.xml
MotionScene
ConstraintSet
ConstraintSet
View
Constraint
<MotionScene>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@id/button"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginStart="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent">
<CustomAttribute
motion:attributeName="BackgroundColor"
motion:customColorValue="#D81B60" />
</Constraint>
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@id/button"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginEnd="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintTop_toTopOf="parent">
<CustomAttribute
motion:attributeName="BackgroundColor"
motion:customColorValue="#9999FF" />
</Constraint>
</ConstraintSet>
</MotionScene>
<MotionScene>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@id/button"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginStart="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent">
<CustomAttribute
motion:attributeName="BackgroundColor"
motion:customColorValue="#D81B60" />
</Constraint>
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@id/button"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginEnd="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintTop_toTopOf="parent">
<CustomAttribute
motion:attributeName="BackgroundColor"
motion:customColorValue="#9999FF" />
</Constraint>
</ConstraintSet>
</MotionScene>
xml/scene.xml
MotionScene
ConstraintSet
ConstraintSet
layout/motion.xml
MotionLayout
View
Helpers
View
ConstraintView
Helpers
View
Constraint
layout_description=“@xml/scene
xml/scene.xml
MotionScene
ConstraintSet
ConstraintSet
layout/motion.xml
MotionLayout
View
Helpers
View
Constraint Transition
Transition
View
Helpers
View
Constraint
layout_description=“@xml/scene
Transitions
Transition
Start End
xml/
motion_scene.xml
MotionScene
Transition
Transition
<MotionScene>
<Transition
motion:constraintSetEnd="@+id/end"
motion:constraintSetStart="@+id/start"
motion:duration="1000"
motion:interpolator="linear">
<OnSwipe
motion:touchAnchorId="@+id/top_image_container"
motion:touchAnchorSide="bottom"
motion:dragDirection="dragUp" />
</Transition>
</MotionScene>
xml/
motion_scene.xml
MotionScene
Transition
Transition
<MotionScene>
<Transition
motion:constraintSetEnd="@+id/end"
motion:constraintSetStart="@+id/start"
motion:duration="1000"
motion:interpolator="linear">
<OnSwipe
motion:touchAnchorId="@+id/top_image_container"
motion:touchAnchorSide="bottom"
motion:dragDirection="dragUp" />
</Transition>
</MotionScene>
xml/
motion_scene.xml
MotionScene
Transition
Transition
<MotionScene>
<Transition
motion:constraintSetEnd="@+id/end"
motion:constraintSetStart="@+id/start"
motion:duration="1000"
motion:interpolator="linear">
<OnSwipe
motion:touchAnchorId="@+id/top_image_container"
motion:touchAnchorSide="bottom"
motion:dragDirection="dragUp" />
</Transition>
</MotionScene>
Or OnClick
xml/scene.xml
MotionScene
ConstraintSet
ConstraintSet
layout/motion.xml
MotionLayout
View
Helpers
View
Constraint Transition
Transition
View
Helpers
View
Constraint
layout_description=“@xml/scene
xml/scene.xml
MotionScene
ConstraintSet
ConstraintSet
layout/motion.xml
MotionLayout
View
Helpers
View
Constraint Transition
Transition
KeyFrameSet
ViewKeyPosition
ViewKeyAttributes
ViewKeyCycle
View
Helpers
ViewKeyTimeCycle
ViewKeyTrigger
View
Constraint
layout_description=“@xml/scene
KeyFrameSets
KeyFrame
Transition
Start End
Transition
Start End
Keyframe(s)
KeyPosition
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@id/button"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginStart="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent" />
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@id/button"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginEnd="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintTop_toTopOf="parent" />
</ConstraintSet>
<Transition>
<KeyFrameSet>
<KeyPosition
motion:keyPositionType="pathRelative"
motion:percentY="-0.25"
motion:framePosition="50"
motion:target="@id/button"/>
</KeyFrameSet>
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@id/button"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginStart="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent">
</Constraint>
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@id/button"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginEnd="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintTop_toTopOf="parent">
</Constraint>
</ConstraintSet>
<Transition>
<KeyFrameSet>
<KeyPosition
motion:keyPositionType="pathRelative"
motion:percentY="-0.25"
motion:framePosition="50"
motion:target="@id/button"/>
</KeyFrameSet>
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@id/button"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginStart="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent">
</Constraint>
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@id/button"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginEnd="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintTop_toTopOf="parent">
</Constraint>
</ConstraintSet>
KeyAttributes
<KeyFrameSet>
<KeyAttribute
android:scaleX="2"
android:scaleY="2"
android:rotation="-45"
motion:framePosition="50"
motion:target="@id/button" />
<KeyPosition
motion:keyPositionType="pathRelative"
motion:percentY="-0.3"
motion:framePosition="50"
motion:target="@id/button"/>
</KeyFrameSet>
<KeyFrameSet>
<KeyAttribute
android:scaleX="2"
android:scaleY="2"
android:rotation="-45"
motion:framePosition="50"
motion:target="@id/button" />
<KeyPosition
motion:keyPositionType="pathRelative"
motion:percentY="-0.3"
motion:framePosition="50"
motion:target="@id/button"/>
</KeyFrameSet>
KeyAttributes
motion:transitionEasing
motion:curveFit
android:visibility
android:alpha
android:elevation
android:rotation
android:rotationX
android:rotationY
android:scaleX
android:scaleY
android:translationX
android:translationY
android:translationZ
motion:transitionPathRotate
motion:framePosition
KeyAttributes
motion:transitionEasing
motion:curveFit
android:visibility
android:alpha
android:elevation
android:rotation
android:rotationX
android:rotationY
android:scaleX
android:scaleY
android:translationX
android:translationY
android:translationZ
motion:transitionPathRotate
motion:framePosition
+ Custom Attributes+ Custom Attributes
<CustomAttribute
motion:attributeName="BackgroundColor"
motion:customColorValue="#D81B60"/>
Sun example
Sunny
Start & End
Position
<KeyPosition
motion:framePosition="50"
motion:percentY="0.1"
motion:percentX="0.5"
motion:keyPositionType="parentRelative"
motion:target="@id/sun"
motion:pathMotionArc="startHorizontal"
/>
Custom Color
<KeyAttribute
motion:framePosition="25"
motion:target="@+id/background">
<CustomAttribute
motion:attributeName="background"
motion:customColorDrawableValue="#97C0FF"
</KeyAttribute>
Time Cycles
<KeyTimeCycle
motion:framePosition="50"
android:rotation="45"
motion:target="@id/sun"
motion:wavePeriod=".5"
motion:waveShape="sin" />
Cycles
Key Cycles
KeyTimeCycles

&

KeyCycles
Key Cycle interpolation
<KeyTimeCycle
motion:framePosition="34"
android:translationX="0dp"
motion:target="@id/button"
motion:waveOffset="0dp"
motion:wavePeriod="2"
motion:waveShape="sin" />
Monotonic splines
• Less prone to overshoot

• Needs to be differentiable and Integrable
Typical Spline
Monotonic Spline
KeyCycle
•Period - 1/pos across space

•Offset - shifts the envelope 

•Attributes - set amplitude of wave
KeyCycles
KeyCycles Period
KeyCycles Value
KeyCycles offset
KeyCycles waveShape
KeyCycles multiple waves
translationX
translationY
KeyCycles multiple waves
translationX
translationY
KeyCycles multiple waves
translationX
translationY
KeyCycles imagination is the limit
translationY
rotation
translationY
rotation
Introducing CycleEditor
• Explore the capabilities of KeyCycles

• XML shown compatible with alpha3

• Features:

• Graph multiple cycles

• Simulate keyCycles effect on a button
KeyTimeCycle
•Period - 1/s (Hz)

•Offset - shifts the envelope 

•Attributes - set amplitude of wave
Same attributes as KeyCycle
KeyTimeCycles
Period (Hz)
KeyTimeCycle
Attribute
translationX
KeyTimeCycles (KeyPosition)
Change the KeyPosition
KeyTimeCycles (Attribute)
Changing value of
android:translationX
KeyTimeCycles
Changing value of
motion:waveOffset
waveOffset
KeyTimeCycles
Changing value of
motion:waveShape
How can you use it?
Coordinator

Layout
Collapsible 

Toolbar
From GitHub
DrawerLayout
From GitHub
ViewPager
From GitHub
New features in alpha 3
percentWidth
percentHeight
New in alpha3
Without percentWidth
With percentWidth
ImageView
ImageView
ImageView
ImageView
ImageView
ImageView
Center transition along X and Y
ImageView
ImageView
ImageView
ImageView
Size transition
ImageView
ImageView
<KeyPosition
motion:target="@id/top_image"
motion:framePosition="90"
motion:percentWidth="0"
motion:percentX="0"
motion:curveFit="linear"
/>
ImageView
ImageView
<KeyPosition
motion:target="@id/top_image"
motion:framePosition="90"
motion:percentWidth="0"
motion:percentX="0"
motion:curveFit="linear"
/>
DeltaX is kept 0 until frame
position 90
ImageView
ImageView
<KeyPosition
motion:target="@id/top_image"
motion:framePosition="90"
motion:percentWidth="0"
motion:percentX="0"
motion:curveFit="linear"
/>
ImageView
ImageView
<KeyPosition
motion:target="@id/top_image"
motion:framePosition="90"
motion:percentWidth="0"
motion:percentX="0"
motion:curveFit="linear"
/>
Delta width is kept 0 until
frame position 90
MultiState
New in alpha3
Transition
Start End
Transition between states
Start State 1State 2
State 3
Current state
Transition1
Transition1
Transition2
Transition3
X
Unless define a
transition between
KeyTrigger
New in alpha3
<KeyFrameSet>
<KeyTrigger
motion:framePosition="10"
motion:onPositiveCross="show"
motion:target="@id/fab"/>
<KeyTrigger
motion:framePosition="20"
motion:onNegativeCross="hide"
motion:target="@id/fab"/>
</KeyFrameSet>
<KeyFrameSet>
<KeyTrigger
motion:framePosition="10"
motion:onPositiveCross="show"
motion:target="@id/fab"/>
<KeyTrigger
motion:framePosition="20"
motion:onNegativeCross="hide"
motion:target="@id/fab"/>
</KeyFrameSet>Calls FloatingActionButton.show()
when it passes 10% and above
<KeyFrameSet>
<KeyTrigger
motion:framePosition="10"
motion:onPositiveCross="show"
motion:target="@id/fab"/>
<KeyTrigger
motion:framePosition="20"
motion:onNegativeCross="hide"
motion:target="@id/fab"/>
</KeyFrameSet>
Calls FloatingActionButton.hide()
when it passes 20% and below
ConstraintLayout 2.0
alpha 4
Alpha 4
• Resize handling

• View visibility

• Attributes rename

• Recyclerview
RecyclerView
+
MotionLayout
How it works
• Handle Gesture

• Provide a similar view

• Add view to Placeholder in MotionLayout

• Recompute bounds

• Run transition
Handling
new PlaceholderGestureHandler(
motionLayout,
recyclerView,
view,
viewType
)
gestureHandler.onTouchEvent(event)
Basic start to end motion
Add size delay
<KeyPosition
motion:framePosition=“40”
motion:percentX=“0”
motion:percentWidth=“0”
motion:percentHeight=“0”
motion:target=“@id/rvItem” />
Add tilt
<KeyAttribute
motion:framePosition=“60”
motion:rotationX=“-20”
motion:target=“@id/rvItem” />
Wrap up
Droidkaigi 2019
Documentation
• Medium Articles:

• Introduction to MotionLayout part I http://bit.ly/2O4AmIz

• Introduction to MotionLayout part II http://bit.ly/2uPuWbw

• Introduction to MotionLayout part III http://bit.ly/2zRjCSj

• Introduction to MotionLayout part IV http://bit.ly/2QqfJaF

• GitHub:

• https://github.com/googlesamples/android-ConstraintLayoutExamples
Droidkaigi 2019
Give us feedback!
• Issue tracker: 

• http://issuetracker.google.com

• ConstraintLayout component

• Twitter

• Nicolas Roard - @camaelon

• John Hoford - @johnhoford

• Takeshi Hagikura - @thagikura
Thanks!
John Hoford
@johnhoford
Nicolas Roard
@camaelon
Takeshi Hagikura
@thagikura

More Related Content

Similar to Deep dive into MotionLayout

Hacktoberfest GDSC BBBDITM.pptx
Hacktoberfest GDSC BBBDITM.pptxHacktoberfest GDSC BBBDITM.pptx
Hacktoberfest GDSC BBBDITM.pptxArishAhmad9
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHubNicolás Tourné
 
Using Git Inside Eclipse, Pushing/Cloning from GitHub
Using Git Inside Eclipse, Pushing/Cloning from GitHubUsing Git Inside Eclipse, Pushing/Cloning from GitHub
Using Git Inside Eclipse, Pushing/Cloning from GitHubAboutHydrology Slides
 
Fundamentals of Git
Fundamentals of GitFundamentals of Git
Fundamentals of Gitcmckni3
 
Intro to Git, GitHub, and Devpost
Intro to Git, GitHub, and DevpostIntro to Git, GitHub, and Devpost
Intro to Git, GitHub, and DevpostAndrew Kerr
 
GDSC PCE Hacktoberfest 1.pptx
GDSC PCE Hacktoberfest 1.pptxGDSC PCE Hacktoberfest 1.pptx
GDSC PCE Hacktoberfest 1.pptxAnandMenon54
 
Hacktoberfest GDSC Pillai College of Engineering
Hacktoberfest GDSC Pillai College of EngineeringHacktoberfest GDSC Pillai College of Engineering
Hacktoberfest GDSC Pillai College of EngineeringAnandMenon54
 
Git and Github.pptx
Git and Github.pptxGit and Github.pptx
Git and Github.pptxaymanessam16
 
Git, GitHub and Open Source
Git, GitHub and Open SourceGit, GitHub and Open Source
Git, GitHub and Open SourceLorna Mitchell
 
GitHub API 101 with Python and Jupyter Notebooks
GitHub API 101 with Python and Jupyter NotebooksGitHub API 101 with Python and Jupyter Notebooks
GitHub API 101 with Python and Jupyter NotebooksAll Things Open
 
Autobuilder2 Yocto Project Summit Lyon 2019
Autobuilder2 Yocto Project Summit Lyon 2019Autobuilder2 Yocto Project Summit Lyon 2019
Autobuilder2 Yocto Project Summit Lyon 2019Marco Cavallini
 
10th php indonesia surabaya meetup
10th php indonesia surabaya meetup10th php indonesia surabaya meetup
10th php indonesia surabaya meetupTaufan Aditya
 
Git extension-training
Git extension-trainingGit extension-training
Git extension-trainingEric Guo
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notesglen_a_smith
 
Git introduction for Beginners
Git introduction for BeginnersGit introduction for Beginners
Git introduction for BeginnersMortezaTaghaddomi
 
WTF is GitOps and Why You Should Care?
WTF is GitOps and Why You Should Care?WTF is GitOps and Why You Should Care?
WTF is GitOps and Why You Should Care?Weaveworks
 

Similar to Deep dive into MotionLayout (20)

Hacktoberfest GDSC BBBDITM.pptx
Hacktoberfest GDSC BBBDITM.pptxHacktoberfest GDSC BBBDITM.pptx
Hacktoberfest GDSC BBBDITM.pptx
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Using Git Inside Eclipse, Pushing/Cloning from GitHub
Using Git Inside Eclipse, Pushing/Cloning from GitHubUsing Git Inside Eclipse, Pushing/Cloning from GitHub
Using Git Inside Eclipse, Pushing/Cloning from GitHub
 
Fundamentals of Git
Fundamentals of GitFundamentals of Git
Fundamentals of Git
 
Github
GithubGithub
Github
 
Intro to Git, GitHub, and Devpost
Intro to Git, GitHub, and DevpostIntro to Git, GitHub, and Devpost
Intro to Git, GitHub, and Devpost
 
Kotti 紹介
Kotti 紹介Kotti 紹介
Kotti 紹介
 
GDSC PCE Hacktoberfest 1.pptx
GDSC PCE Hacktoberfest 1.pptxGDSC PCE Hacktoberfest 1.pptx
GDSC PCE Hacktoberfest 1.pptx
 
Hacktoberfest GDSC Pillai College of Engineering
Hacktoberfest GDSC Pillai College of EngineeringHacktoberfest GDSC Pillai College of Engineering
Hacktoberfest GDSC Pillai College of Engineering
 
Git and Github.pptx
Git and Github.pptxGit and Github.pptx
Git and Github.pptx
 
Git, GitHub and Open Source
Git, GitHub and Open SourceGit, GitHub and Open Source
Git, GitHub and Open Source
 
GitHub API 101 with Python and Jupyter Notebooks
GitHub API 101 with Python and Jupyter NotebooksGitHub API 101 with Python and Jupyter Notebooks
GitHub API 101 with Python and Jupyter Notebooks
 
Autobuilder2 Yocto Project Summit Lyon 2019
Autobuilder2 Yocto Project Summit Lyon 2019Autobuilder2 Yocto Project Summit Lyon 2019
Autobuilder2 Yocto Project Summit Lyon 2019
 
Giddy Up on GitHub
Giddy Up on GitHubGiddy Up on GitHub
Giddy Up on GitHub
 
10th php indonesia surabaya meetup
10th php indonesia surabaya meetup10th php indonesia surabaya meetup
10th php indonesia surabaya meetup
 
Git extension-training
Git extension-trainingGit extension-training
Git extension-training
 
Copy of GDSC Hacktober.pptx
Copy of GDSC Hacktober.pptxCopy of GDSC Hacktober.pptx
Copy of GDSC Hacktober.pptx
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Git introduction for Beginners
Git introduction for BeginnersGit introduction for Beginners
Git introduction for Beginners
 
WTF is GitOps and Why You Should Care?
WTF is GitOps and Why You Should Care?WTF is GitOps and Why You Should Care?
WTF is GitOps and Why You Should Care?
 

Recently uploaded

Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfYashikaSharma391629
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 

Recently uploaded (20)

Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 

Deep dive into MotionLayout