SlideShare a Scribd company logo
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
Constraint
View
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
Constraint
View
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
View
KeyPosition
View
KeyAttributes
View
KeyCycle
View
Helpers
View
KeyTimeCycle
View
KeyTrigger
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 1
State 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 Droidkaigi2019thagikura 190208135940

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
All Things Open
 
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 Droidkaigi2019thagikura 190208135940 (20)

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 & Why Should You Care?
WTF is GitOps & Why Should You Care?WTF is GitOps & Why Should You Care?
WTF is GitOps & Why Should You 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?
WTF is GitOps and Why You Should Care?
 
Building a Kubernetes Powered Central Go Modules Repository
Building a Kubernetes Powered Central Go Modules RepositoryBuilding a Kubernetes Powered Central Go Modules Repository
Building a Kubernetes Powered Central Go Modules Repository
 
Introduction To Git
Introduction To GitIntroduction To Git
Introduction To Git
 
GITHUB
GITHUBGITHUB
GITHUB
 
R1-intro-to-go.pptx
R1-intro-to-go.pptxR1-intro-to-go.pptx
R1-intro-to-go.pptx
 
Git hub
Git hubGit hub
Git hub
 
Git for the Android Developer
Git for the Android DeveloperGit for the Android Developer
Git for the Android Developer
 

More from Vitali Pekelis

More from Vitali Pekelis (20)

Droidkaigi 2019
Droidkaigi 2019Droidkaigi 2019
Droidkaigi 2019
 
Google i o &amp; android q changes 2019
Google i o &amp; android q changes 2019Google i o &amp; android q changes 2019
Google i o &amp; android q changes 2019
 
Android Q 2019
Android Q 2019Android Q 2019
Android Q 2019
 
Advanced #6 clean architecture
Advanced #6  clean architectureAdvanced #6  clean architecture
Advanced #6 clean architecture
 
Advanced #4 GPU & Animations
Advanced #4   GPU & AnimationsAdvanced #4   GPU & Animations
Advanced #4 GPU & Animations
 
Advanced #2 networking
Advanced #2   networkingAdvanced #2   networking
Advanced #2 networking
 
Advanced #2 threading
Advanced #2   threadingAdvanced #2   threading
Advanced #2 threading
 
Advanced #1 cpu, memory
Advanced #1   cpu, memoryAdvanced #1   cpu, memory
Advanced #1 cpu, memory
 
All the support you need. Support libs in Android
All the support you need. Support libs in AndroidAll the support you need. Support libs in Android
All the support you need. Support libs in Android
 
How to build Sdk? Best practices
How to build Sdk? Best practicesHow to build Sdk? Best practices
How to build Sdk? Best practices
 
Di &amp; dagger
Di &amp; daggerDi &amp; dagger
Di &amp; dagger
 
Android design patterns
Android design patternsAndroid design patterns
Android design patterns
 
Advanced #3 threading
Advanced #3  threading Advanced #3  threading
Advanced #3 threading
 
Mobile ui fruit or delicious sweets
Mobile ui  fruit or delicious sweetsMobile ui  fruit or delicious sweets
Mobile ui fruit or delicious sweets
 
Lecture #4 c loaders and co.
Lecture #4 c   loaders and co.Lecture #4 c   loaders and co.
Lecture #4 c loaders and co.
 
Session #4 b content providers
Session #4 b  content providersSession #4 b  content providers
Session #4 b content providers
 
Advanced #2 - ui perf
 Advanced #2 - ui perf Advanced #2 - ui perf
Advanced #2 - ui perf
 
Android meetup
Android meetupAndroid meetup
Android meetup
 
Android design lecture #3
Android design   lecture #3Android design   lecture #3
Android design lecture #3
 
From newbie to ...
From newbie to ...From newbie to ...
From newbie to ...
 

Recently uploaded

AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
Alluxio, Inc.
 

Recently uploaded (20)

Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning Framework
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
 
GraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysisGraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysis
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
10 Essential Software Testing Tools You Need to Know About.pdf
10 Essential Software Testing Tools You Need to Know About.pdf10 Essential Software Testing Tools You Need to Know About.pdf
10 Essential Software Testing Tools You Need to Know About.pdf
 
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdfImplementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting software
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Kraków
 
How to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabberHow to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabber
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 

Droidkaigi2019thagikura 190208135940