SlideShare ist ein Scribd-Unternehmen logo
1 von 122
Downloaden Sie, um offline zu lesen
ConstraintLayout
Making Animations
MotionLayout
John Hoford @johnhoford
{ droidcon Tel Aviv}
ConstraintLayout 2.0 alpha2
★ Layout
★ Helpers
★ Rendering
★ Live Resize
★ MotionLayout
★ APIs
{ droidcon Tel Aviv}
ConstraintLayout 2.0 alpha2
★ Layout
★ Helpers
★ Rendering
★ Live Resize
★ MotionLayout
★ APIs
{ droidcon Tel Aviv}
Animation
{ droidcon Tel Aviv}
Why add Animation?
★Provide Context
★Convey Meaning
★Delight
★Distract
{ droidcon Tel Aviv}
Why add Animation
★Provide Context
Where did the UI come from?
Where did it go?
{ droidcon Tel Aviv}
Why add Animation
★Convey Meaning
Use motion to inform the user
(Normally animated content)
{ droidcon Tel Aviv}
Why add Animation
★Delight
Visually interesting animations
✴ Make your app memorable
✴ Indicates app is high quality
{ droidcon Tel Aviv}
Why add Animation
★Distract
•Only when necessary
•Startup screen
•Performing work
{ droidcon Tel Aviv}
Animation Types
Animated content
Transition Layouts
Motion
Property Animation
{ droidcon Tel Aviv}
Animation Types
Animated content
Transition Layouts
Motion
Lottie, Animated Vector Drawable, GIFs, etc.
TransitionManager
CoordinatorLayout
Property Animation Property animation framework (code)
{ droidcon Tel Aviv}
MotionLayout
Animated content Lottie, Animated Vector Drawable, GIFs, etc.
TransitionManager
CoordinatorLayout
Property animation framework (code)
Transition Layouts
Motion
Property Animation
{ droidcon Tel Aviv}
MotionLayout
{ droidcon Tel Aviv}
MotionLayout basics
★ Sub class of ConstraintLayout

★ Extends CL2.0s LayoutDescription to have full animations capabilities

★ Provides a division between views and layout & animation
class MotionLayout extends ConstraintLayout
app:layoutDescription=“@xml/motion_scene”
layout/
motion.xml
View
Views
xml/

motion_scene.xml
View
Constraints
View
KeyFrames
{ droidcon Tel Aviv}
MotionLayout goals
★ Lower cost of maintain programatic animations
★ Richly Declarative (can support tooling)
★ A platform for us to deliver more capability over time
{ droidcon Tel Aviv}
It’s Declarative
{ droidcon Tel Aviv}
Declarative Approach
★ Rich easier model
★ We can build tooling
{ droidcon Tel Aviv}
MotionLayout
Hello World
{ droidcon Tel Aviv}
Simple ConstrintLayout
• Controls in a panel
{ droidcon Tel Aviv}
Convert To MotionLayout
•Rename ConstrintLayout to :
android.support.constraint.motion.MotionLayout
•Add attribute:
app:layoutDescription="@xml/motion_scene"
•Creat res/xml/motion_scene.xml
•In motion scene…
<?xml version="1.0" encoding="utf-8"?>
<MotionScene …>
<Transition
motion:constraintSetStart="@+id/start"
motion:constraintSetEnd="@+id/end">
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id=“@+id/control”…/>
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id=“@+id/control" …/>
</ConstraintSet>
</MotionScene>
<?xml version="1.0" encoding="utf-8"?>
<MotionScene …>
<Transition
motion:constraintSetStart="@+id/start"
motion:constraintSetEnd="@+id/end">
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id=“@+id/control”…/>
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id=“@+id/control" …/>
</ConstraintSet>
</MotionScene>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id=“@+id/control"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
motion:layout_constraintBottom_toBottomOf=“parent"
motion:layout_constraintEnd_toStartOf="@+id/imageButton2"
motion:layout_constraintStart_toStartOf="parent"
/>
</ConstraintSet>
<?xml version="1.0" encoding="utf-8"?>
<MotionScene …>
<Transition
motion:constraintSetStart="@+id/start"
motion:constraintSetEnd="@+id/end">
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id=“@+id/control”…/>
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id=“@+id/control" …/>
</ConstraintSet>
</MotionScene>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id=“@+id/control"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
motion:layout_constraintTop_toTopOf=“parent”
motion:layout_constraintEnd_toStartOf="@+id/imageButton2"
motion:layout_constraintStart_toStartOf="parent"
/>
</ConstraintSet>
{ droidcon Tel Aviv}
3 ways to trigger
Animation
• Programatic
• Built in OnTouch or OnSwipe
• Nested - MotionLayout containing MotionLayout
{ droidcon Tel Aviv}
Advantages
• All you views are in one layout.
•The animation effects & layout are unified.
•You can have matching layouts for landscape, screen size, etc.
•You can view this from the IDE
{ droidcon Tel Aviv}
MotionLayout
Architecture
{ droidcon Tel Aviv}
xml/motion_scene.xml
MotionScene
ConstraintSet
ConstraintSet
Major components
layout/motion.xml
MotionLayout
View
Helpers
View
Constraints
Transition
Transition
KeyFrameSet
ViewKeyPosition
ViewKeyAttributes
View
KeyCycle
View
Helpers
app:layoutDescription =
{ droidcon Tel Aviv}
xml/motion_scene.xml
MotionScene
ConstraintSet
ConstraintSet
MotionLayout
layout/motion.xml
MotionLayout
View
Helpers
View
Constraints
Transition
Transition
KeyFrameSet
ViewKeyPosition
ViewKeyAttributes
View
KeyCycle
View
Helpers
app:layoutDescription =
{ droidcon Tel Aviv}
MotionLayout XML attributes
★ app:layoutDescription =”reference”
★ app:applyMotionScene =”boolean” [ default = true ]
★ app:showPaths =”boolean” [ default = false]
★ app:progress =”float”
★ app:currentState =”reference”
{ droidcon Tel Aviv}
Transition API
★ transitionToEnd()
★ transitionToStart()
★ transitionToState(int state)
★ setProgress(float value) [0 .. 1]
{ droidcon Tel Aviv}
xml/motion_scene.xml
MotionScene
ConstraintSet
ConstraintSet
ConstraintSet
layout/motion.xml
MotionLayout
View
Helpers
View
Constraints
Transition
Transition
KeyFrameSet
ViewKeyPosition
ViewKeyAttributes
View
KeyCycle
View
Helpers
app:layoutDescription =
{ droidcon Tel Aviv}
ConstraintSet
★ Encapsulate all the rules for a layout
★ Apply ConstraintSet to an existing layout
★ Switch between multiple ConstraintSets
★ Basic animation capabilities using TransitionManager
{ droidcon Tel Aviv}
Start End
Seekable Transition
Start
ConstraintSet
End
ConstraintSet
Interpolation
{ droidcon Tel Aviv}
Interpolated Attributes
★ Position, Dimensions
★ Visibility & Alpha
★ Translation, Rotation, Scale, Elevation
★ Custom attributes
{ droidcon Tel Aviv}
Custom Attributes
★ Extension to ConstraintSet
★ Define values for any attribute
★Specify the type
★Specify the setter name
string
color
integer
float
dimension
boolean
<ConstraintSet ...>
<Constraint ...>
<CustomAttribute
motion:attributeName="backgroundColor"
motion:customColorValue="#D81B60" />
</Constraint>
</ConstraintSet>
★call 

setBackgroundColor(0xD81B60);
{ droidcon Tel Aviv}
xml/motion_scene.xml
MotionScene
ConstraintSet
ConstraintSet
Transition
layout/motion.xml
MotionLayout
View
Helpers
View
Constraints
Transition
Transition
KeyFrameSet
ViewKeyPosition
ViewKeyAttributes
View
KeyCycle
View
Helpers
app:layoutDescription =
{ droidcon Tel Aviv}
Transition XML attributes
★ motion:constraintSetStart =”reference”
★ motion:constraintSetEnd =”reference”
★ motion:duration =”int” [ milliseconds ]
★ motion:interpolator = ”linear” (easeInOut, easeOut, …
{ droidcon Tel Aviv}
MotionLayout
Example walk through
{ droidcon Tel Aviv}
<?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()
}
}
}
{ droidcon Tel Aviv}
<?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" />
{ droidcon Tel Aviv}
{ droidcon Tel Aviv}
Utilities
★ MockView
★ ImageFilterView : Contrast, Saturation, Warmth, crossfade
{ droidcon Tel Aviv}
<android.support.constraint.motion.MotionLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/motionLayout"
app:layoutDescription="@xml/scene_04"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.constraint.utils.ImageFilterView
android:id="@+id/image"
android:background="@color/colorAccent"
android:src="@drawable/roard"
app:altSrc="@drawable/hoford"
android:layout_width="64dp"
android:layout_height="64dp"/>
</android.support.constraint.motion.MotionLayout>
<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">
<OnSwipe
motion:dragDirection="dragRight"
motion:touchAnchorId="@id/image"
motion:touchAnchorSide="right" />
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@+id/image"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginStart="8dp"
motion:touchAnchorSide="right" />
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@+id/image"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginStart="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent">
<CustomAttribute
motion:attributeName="crossfade"
motion:customFloatValue="0" />
</Constraint>
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
motion:touchAnchorSide="right" />
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@+id/image"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginStart="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent">
<CustomAttribute
motion:attributeName="crossfade"
motion:customFloatValue="0" />
</Constraint>
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
</Constraint>
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@id/image"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginEnd="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintTop_toTopOf="parent">
<CustomAttribute
motion:attributeName="crossfade"
motion:customFloatValue="1" />
</Constraint>
</ConstraintSet>
</MotionScene>
</Constraint>
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@id/image"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginEnd="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintTop_toTopOf="parent">
<CustomAttribute
motion:attributeName="crossfade"
motion:customFloatValue="1" />
</Constraint>
</ConstraintSet>
</MotionScene>
{ droidcon Tel Aviv}
{ droidcon Tel Aviv}
Events
{ droidcon Tel Aviv}
Events
★ TransitionListener
★ OnClick
★ OnSwipe
{ droidcon Tel Aviv}
TransitionListener
public interface TransitionListener {
void onTransitionChange(MotionLayout motionLayout,
int startId, int endId,
float progress);
void onTransitionCompleted(MotionLayout motionLayout,
int currentId);
}
{ droidcon Tel Aviv}
OnSwipe
<OnSwipe
motion:dragDirection="dragUp"
motion:touchAnchorId="@+id/widget"
motion:touchAnchorSide=“top" />
dragDirection
dragUp
dragDown
dragRight
dragLeft
touchAnchorId
touchAnchorSide
top
bottom
left
right
OnSwipe
<OnSwipe
motion:dragDirection="dragUp"
motion:touchAnchorId="@+id/widget"
motion:touchAnchorSide=“top" />
Create your animation
OnSwipe “plays” it
OnSwipe: Top
touchAnchorSide : TOP
OnSwipe: Right
touchAnchorSide : RIGHT
OnSwipe: Bottom
touchAnchorSide : BOTTOM
OnSwipe: Left
touchAnchorSide : LEFT
Touch Up / Release
Takes in account velocity
Choose a continuous velocity curve to reach the endpoints
with a velocity of zero
{ droidcon Tel Aviv}
OnClick
<OnClick motion:target="@+id/run" />
mode

• transitionToEnd
• toggle
• transitionToStart
• jumpToEnd
• jumpToStart
OnClick
{ droidcon Tel Aviv}
xml/motion_scene.xml
MotionScene
ConstraintSet
ConstraintSet
Major components
layout/motion.xml
MotionLayout
View
Helpers
View
Constraints
Transition
Transition
KeyFrameSet
ViewKeyPosition
ViewKeyAttributes
View
KeyCycle
View
Helpers
app:layoutDescription =
{ droidcon Tel Aviv}
Keyframes
{ droidcon Tel Aviv}
Keyframe
a rendez-vous in time
{ droidcon Tel Aviv}
Keyframes
★ Position
★ Attributes
★ Cycles
★ …and more
{ droidcon Tel Aviv}
Position
Driving layout bounds
KeyFrameSet
<KeyFrameSet>
</KeyFrameSet>
KeyFrameSet
<KeyFrameSet>
<KeyPosition
motion:target="@+id/widget"
motion:framePosition="50"
motion:percentX=“1.0” />
</KeyFrameSet>
KeyFrameSet
<KeyFrameSet>
<KeyPosition
motion:target="@+id/widget"
motion:framePosition="50"
motion:percentX=“1.0”
motion:sizePercent=“0.0"
/>
</KeyFrameSet>
KeyFrameSet
<KeyFrameSet>
<KeyPosition
motion:target="@+id/widget"
motion:framePosition="50"
motion:percentX=“1.0”
motion:percentY=“0.3”
motion:sizePercent=“0.0"
/>
</KeyFrameSet>
{ droidcon Tel Aviv}
Coordinate Systems
{ droidcon Tel Aviv}
{ droidcon Tel Aviv}
Start
End
{ droidcon Tel Aviv}
parentRelative0
X
Y
{ droidcon Tel Aviv}
deltaRelative
Y
X
{ droidcon Tel Aviv}
pathRelative
XY
KeyFramePosition
<KeyPosition
motion:framePosition="50"
motion:percentX="1"
motion:target=“@id/imageButton*” />
{ droidcon Tel Aviv}
Attributes
post layout attributes
KeyFrameSet
<KeyFrameSet>
<KeyPosition… />
<KeyAttributes
motion:target="@+id/widget"
motion:framePosition="25"
android:rotation=“45”
/>
</KeyFrameSet>
KeyFrameSet
<KeyFrameSet>
<KeyPosition… />
<KeyAttributes
motion:target="@+id/widget"
motion:framePosition="25"
android:rotation=“45”/>
<KeyAttributes
motion:target="@+id/widget"
motion:framePosition="50"
android:rotation=“0”/>
</KeyFrameSet>
KeyAttributes support
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:progress
+ Custom Attributes
<CustomAttribute
motion:attributeName="BackgroundColor"
motion:customColorValue="#D81B60"/>
{ droidcon Tel Aviv}
oscillation of
post layout attributes
Cycles
KeyCycle
<KeyFrameSet>
<KeyPosition…/>
<KeyAttributes…/> <KeyAttributes…/>
<KeyCycle
motion:target="@+id/widget"
motion:framePosition="0"
motion:wavePeriod=“0”
motion:translationX=“0.0"
/>
<KeyCycle
motion:target="@+id/widget"
motion:framePosition="50"
motion:wavePeriod=“2”
motion:translationX=“30dp"
/>
</KeyFrameSet>
{ droidcon Tel Aviv}
Code
KeyCycle
Value (attributes)
{ droidcon Tel Aviv}
Code
KeyCycle
Period
{ droidcon Tel Aviv}
Code
KeyCycle WaveForms
KeyCycle
<KeyFrameSet>
<KeyPosition…/>
<KeyAttributes…/> <KeyAttributes…/>
<KeyCycle
motion:target="@+id/widget"
motion:framePosition="0"
motion:wavePeriod=“0”
motion:translationX=“0.0"
/>
<KeyCycle
motion:target="@+id/widget"
motion:framePosition="50"
motion:wavePeriod=“2”
motion:translationX=“30dp"
/>
</KeyFrameSet>
{ droidcon Tel Aviv}
Applications
{ droidcon Tel Aviv}
Integration
★ CoordinatorLayout
★ DrawerLayout
★ ViewPager
★ MotionLayout
{ droidcon Tel Aviv}
motion:progress
{ droidcon Tel Aviv}
CoordinatorLayout
Collapsible
Toolbar
From GitHub
{ droidcon Tel Aviv}
DrawerLayout
From GitHub
{ droidcon Tel Aviv}
ViewPager
From GitHub
{ droidcon Tel Aviv}
From GitHub
Nested MotionLayout
{ droidcon Tel Aviv}
{ droidcon Tel Aviv}
{ droidcon Tel Aviv}
Whats Next…
★ ConstraintLayout 2.0 alpha3
★ KeyTimeCycles
★ Arc mode
★ Multi-state swipe
★ Helpers
★ Alpha MotionEditor
{ droidcon Tel Aviv}
Documentation
★ Online Documentation: https://developer.android.com/reference/android/
support/constraint/motion/package-summary
★ Medium Articles:
★ Introduction to MotionLayout - Part I, II, III, IV :

http://bit.ly/2O4AmIz
★ GitHub

https://github.com/googlesamples/android-ConstraintLayoutExamples
Thanks!
John Hoford
@johnhoford
Thanks!
John Hoford
@johnhoford
Constraint-ly motion - making your app dance - John Hoford, Google

Weitere ähnliche Inhalte

Was ist angesagt?

Eclipse based products
Eclipse based productsEclipse based products
Eclipse based products
ESPRIT
 
Spring AOP Introduction
Spring AOP IntroductionSpring AOP Introduction
Spring AOP Introduction
b0ris_1
 
SiriusCon 2015 - Breathe Life into Your Designer!
SiriusCon 2015 - Breathe Life into Your Designer!SiriusCon 2015 - Breathe Life into Your Designer!
SiriusCon 2015 - Breathe Life into Your Designer!
melbats
 

Was ist angesagt? (20)

TechEvent Graal(VM) Performance Interoperability
TechEvent Graal(VM) Performance InteroperabilityTechEvent Graal(VM) Performance Interoperability
TechEvent Graal(VM) Performance Interoperability
 
Agile Development with OSGi
Agile Development with OSGiAgile Development with OSGi
Agile Development with OSGi
 
Eclipse based products
Eclipse based productsEclipse based products
Eclipse based products
 
Spring AOP Introduction
Spring AOP IntroductionSpring AOP Introduction
Spring AOP Introduction
 
How to deploy machine learning models in the Cloud
How to deploy machine learning models in the CloudHow to deploy machine learning models in the Cloud
How to deploy machine learning models in the Cloud
 
The Prana IoC Container
The Prana IoC ContainerThe Prana IoC Container
The Prana IoC Container
 
SiriusCon 2015 - Breathe Life into Your Designer!
SiriusCon 2015 - Breathe Life into Your Designer!SiriusCon 2015 - Breathe Life into Your Designer!
SiriusCon 2015 - Breathe Life into Your Designer!
 
Apollo. The client we deserve
Apollo. The client we deserveApollo. The client we deserve
Apollo. The client we deserve
 
EclipseCon France 2016 - Sirius 4.0: Let me Sirius that for you!
EclipseCon France 2016 - Sirius 4.0: Let me Sirius that for you!EclipseCon France 2016 - Sirius 4.0: Let me Sirius that for you!
EclipseCon France 2016 - Sirius 4.0: Let me Sirius that for you!
 
Java 8 - Completable Future
Java 8 - Completable FutureJava 8 - Completable Future
Java 8 - Completable Future
 
"Production Driven Development", Serhii Kalinets
"Production Driven Development", Serhii Kalinets"Production Driven Development", Serhii Kalinets
"Production Driven Development", Serhii Kalinets
 
Boost your API with GraphQL
Boost your API with GraphQLBoost your API with GraphQL
Boost your API with GraphQL
 
Vitaliy Makogon: Migration to ivy. Angular component libraries with IVY support.
Vitaliy Makogon: Migration to ivy. Angular component libraries with IVY support.Vitaliy Makogon: Migration to ivy. Angular component libraries with IVY support.
Vitaliy Makogon: Migration to ivy. Angular component libraries with IVY support.
 
Angular 2 Essential Training
Angular 2 Essential Training Angular 2 Essential Training
Angular 2 Essential Training
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
 
SPRING BOOT DANS UN CONTAINER OUTILS ET PRATIQUES
 SPRING BOOT DANS UN CONTAINER OUTILS ET PRATIQUES SPRING BOOT DANS UN CONTAINER OUTILS ET PRATIQUES
SPRING BOOT DANS UN CONTAINER OUTILS ET PRATIQUES
 
Smokey and the Multi-Armed Bandit Featuring BERT Reynolds Updated
Smokey and the Multi-Armed Bandit Featuring BERT Reynolds UpdatedSmokey and the Multi-Armed Bandit Featuring BERT Reynolds Updated
Smokey and the Multi-Armed Bandit Featuring BERT Reynolds Updated
 
SETCON'18 - Ilya labacheuski - GraphQL adventures
SETCON'18 - Ilya labacheuski - GraphQL adventuresSETCON'18 - Ilya labacheuski - GraphQL adventures
SETCON'18 - Ilya labacheuski - GraphQL adventures
 
ServiceWorkerとES6 Modules時代のTypescript開発考察
ServiceWorkerとES6 Modules時代のTypescript開発考察ServiceWorkerとES6 Modules時代のTypescript開発考察
ServiceWorkerとES6 Modules時代のTypescript開発考察
 
Micro-Benchmarking Considered Harmful
Micro-Benchmarking Considered HarmfulMicro-Benchmarking Considered Harmful
Micro-Benchmarking Considered Harmful
 

Ähnlich wie Constraint-ly motion - making your app dance - John Hoford, Google

Android app development basics
Android app development basicsAndroid app development basics
Android app development basics
Anton Narusberg
 
Mobile Software Engineering Crash Course - C03 Android
Mobile Software Engineering Crash Course - C03 AndroidMobile Software Engineering Crash Course - C03 Android
Mobile Software Engineering Crash Course - C03 Android
Mohammad Shaker
 

Ähnlich wie Constraint-ly motion - making your app dance - John Hoford, Google (20)

Motion Layout - Easy animations for everyone
Motion Layout - Easy animations for everyoneMotion Layout - Easy animations for everyone
Motion Layout - Easy animations for everyone
 
Animate Me! if you don't do it for me, do it for Chet - DroidconLondon2015
Animate Me! if you don't do it for me, do it for Chet - DroidconLondon2015Animate Me! if you don't do it for me, do it for Chet - DroidconLondon2015
Animate Me! if you don't do it for me, do it for Chet - DroidconLondon2015
 
Animate Me, if you don't do it for me do it for chet (DroidCon Paris)
Animate Me, if you don't do it for me do it for chet (DroidCon Paris)Animate Me, if you don't do it for me do it for chet (DroidCon Paris)
Animate Me, if you don't do it for me do it for chet (DroidCon Paris)
 
Fake it 'til you make it
Fake it 'til you make itFake it 'til you make it
Fake it 'til you make it
 
Beauty Treatment for your Android Application
Beauty Treatment for your Android ApplicationBeauty Treatment for your Android Application
Beauty Treatment for your Android Application
 
Lecture #1 Creating your first android project
Lecture #1  Creating your first android projectLecture #1  Creating your first android project
Lecture #1 Creating your first android project
 
Tips & Tricks to spice up your Android app
Tips & Tricks to spice up your Android appTips & Tricks to spice up your Android app
Tips & Tricks to spice up your Android app
 
Make your app dance with MotionLayout
Make your app dance with MotionLayoutMake your app dance with MotionLayout
Make your app dance with MotionLayout
 
Android animation made easy with MotionLayout at Android bangkok conference 2020
Android animation made easy with MotionLayout at Android bangkok conference 2020Android animation made easy with MotionLayout at Android bangkok conference 2020
Android animation made easy with MotionLayout at Android bangkok conference 2020
 
Design Patterns for Tablets and Smartphones
Design Patterns for Tablets and SmartphonesDesign Patterns for Tablets and Smartphones
Design Patterns for Tablets and Smartphones
 
Android Workshop
Android WorkshopAndroid Workshop
Android Workshop
 
21 android2 updated
21 android2 updated21 android2 updated
21 android2 updated
 
Migrating a large scale banking app to compose
Migrating a large scale banking app to composeMigrating a large scale banking app to compose
Migrating a large scale banking app to compose
 
Geekcamp Android
Geekcamp AndroidGeekcamp Android
Geekcamp Android
 
Mobile HTML, CSS, and JavaScript
Mobile HTML, CSS, and JavaScriptMobile HTML, CSS, and JavaScript
Mobile HTML, CSS, and JavaScript
 
Android app development basics
Android app development basicsAndroid app development basics
Android app development basics
 
Mobile Software Engineering Crash Course - C03 Android
Mobile Software Engineering Crash Course - C03 AndroidMobile Software Engineering Crash Course - C03 Android
Mobile Software Engineering Crash Course - C03 Android
 
From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)
 
Android JetPack: easy navigation with the new Navigation Controller
Android JetPack: easy navigation with the new Navigation ControllerAndroid JetPack: easy navigation with the new Navigation Controller
Android JetPack: easy navigation with the new Navigation Controller
 
Advanced Android gReporter
Advanced Android gReporterAdvanced Android gReporter
Advanced Android gReporter
 

Mehr von DroidConTLV

Mehr von DroidConTLV (20)

Mobile Development in the Information Age - Yossi Elkrief, Nike
Mobile Development in the Information Age - Yossi Elkrief, NikeMobile Development in the Information Age - Yossi Elkrief, Nike
Mobile Development in the Information Age - Yossi Elkrief, Nike
 
Doing work in the background - Darryn Campbell, Zebra Technologies
Doing work in the background - Darryn Campbell, Zebra TechnologiesDoing work in the background - Darryn Campbell, Zebra Technologies
Doing work in the background - Darryn Campbell, Zebra Technologies
 
No more video loss - Alex Rivkin, Motorola Solutions
No more video loss - Alex Rivkin, Motorola SolutionsNo more video loss - Alex Rivkin, Motorola Solutions
No more video loss - Alex Rivkin, Motorola Solutions
 
Mobile at Scale: from startup to a big company - Dor Samet, Booking.com
Mobile at Scale: from startup to a big company - Dor Samet, Booking.comMobile at Scale: from startup to a big company - Dor Samet, Booking.com
Mobile at Scale: from startup to a big company - Dor Samet, Booking.com
 
LiveData on Steroids - Giora Shevach + Shahar Ben Moshe, Climacell
LiveData on Steroids - Giora Shevach + Shahar Ben Moshe, ClimacellLiveData on Steroids - Giora Shevach + Shahar Ben Moshe, Climacell
LiveData on Steroids - Giora Shevach + Shahar Ben Moshe, Climacell
 
MVVM In real life - Lea Cohen Tannoudji, Lightricks
MVVM In real life - Lea Cohen Tannoudji, LightricksMVVM In real life - Lea Cohen Tannoudji, Lightricks
MVVM In real life - Lea Cohen Tannoudji, Lightricks
 
Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)
Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)
Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)
 
Building Apps with Flutter - Hillel Coren, Invoice Ninja
Building Apps with Flutter - Hillel Coren, Invoice NinjaBuilding Apps with Flutter - Hillel Coren, Invoice Ninja
Building Apps with Flutter - Hillel Coren, Invoice Ninja
 
New Android Project: The Most Important Decisions - Vasiliy Zukanov
New Android Project: The Most Important Decisions - Vasiliy ZukanovNew Android Project: The Most Important Decisions - Vasiliy Zukanov
New Android Project: The Most Important Decisions - Vasiliy Zukanov
 
Designing a Design System - Shai Mishali, Gett
Designing a Design System - Shai Mishali, GettDesigning a Design System - Shai Mishali, Gett
Designing a Design System - Shai Mishali, Gett
 
The Mighty Power of the Accessibility Service - Guy Griv, Pepper
The Mighty Power of the Accessibility Service - Guy Griv, PepperThe Mighty Power of the Accessibility Service - Guy Griv, Pepper
The Mighty Power of the Accessibility Service - Guy Griv, Pepper
 
Kotlin Multiplatform in Action - Alexandr Pogrebnyak - IceRockDev
Kotlin Multiplatform in Action - Alexandr Pogrebnyak - IceRockDevKotlin Multiplatform in Action - Alexandr Pogrebnyak - IceRockDev
Kotlin Multiplatform in Action - Alexandr Pogrebnyak - IceRockDev
 
Flutter State Management - Moti Bartov, Tikal
Flutter State Management - Moti Bartov, TikalFlutter State Management - Moti Bartov, Tikal
Flutter State Management - Moti Bartov, Tikal
 
Reactive UI in android - Gil Goldzweig Goldbaum, 10bis
Reactive UI in android - Gil Goldzweig Goldbaum, 10bisReactive UI in android - Gil Goldzweig Goldbaum, 10bis
Reactive UI in android - Gil Goldzweig Goldbaum, 10bis
 
Fun with flutter animations - Divyanshu Bhargava, GoHighLevel
Fun with flutter animations - Divyanshu Bhargava, GoHighLevelFun with flutter animations - Divyanshu Bhargava, GoHighLevel
Fun with flutter animations - Divyanshu Bhargava, GoHighLevel
 
DroidconTLV 2019
DroidconTLV 2019DroidconTLV 2019
DroidconTLV 2019
 
Ok google, it's time to bot! - Hadar Franco, Albert + Stav Levi, Monday
Ok google, it's time to bot! - Hadar Franco, Albert + Stav Levi, MondayOk google, it's time to bot! - Hadar Franco, Albert + Stav Levi, Monday
Ok google, it's time to bot! - Hadar Franco, Albert + Stav Levi, Monday
 
Bang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGeneBang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGene
 
Reverse reverse engineering engineering 101 - Royi Benyossef, Samsung NEXT
Reverse reverse engineering engineering 101 - Royi Benyossef, Samsung NEXTReverse reverse engineering engineering 101 - Royi Benyossef, Samsung NEXT
Reverse reverse engineering engineering 101 - Royi Benyossef, Samsung NEXT
 
The Redux State of the Art - Shem Magnezi+Limor Mekaiten, WeWork
The Redux State of the Art - Shem Magnezi+Limor Mekaiten, WeWorkThe Redux State of the Art - Shem Magnezi+Limor Mekaiten, WeWork
The Redux State of the Art - Shem Magnezi+Limor Mekaiten, WeWork
 

Kürzlich hochgeladen

Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
UXDXConf
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
UK Journal
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Peter Udo Diehl
 

Kürzlich hochgeladen (20)

Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdf
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 

Constraint-ly motion - making your app dance - John Hoford, Google