Slide 1

Slide 1 text

DroidconSF 2019 MotionLayout & Motion Editor Animation made easy John Hoford @johnhoford Nicolas Roard @camaelon

Slide 2

Slide 2 text

DroidconSF 2019 So, what is Motion Layout ?

Slide 3

Slide 3 text

DroidconSF 2019 MotionLayout Viewgroup

Slide 4

Slide 4 text

DroidconSF 2019 MotionLayout ConstraintLayout

Slide 5

Slide 5 text

DroidconSF 2019 MotionLayout ConstraintLayout Relative Constraints Center Constraints Dimension Constraints Chains Virtual Layouts Guidelines Barriers Flow Circular Constraints Helpers

Slide 6

Slide 6 text

DroidconSF 2019 What does it do?

Slide 7

Slide 7 text

DroidconSF 2019 MotionLayout Position views Animation Touch Handling State

Slide 8

Slide 8 text

DroidconSF 2019 MotionLayout Position views Animation Touch Handling State

Slide 9

Slide 9 text

DroidconSF 2019 MotionLayout Position views Animation Touch Handling State

Slide 10

Slide 10 text

DroidconSF 2019 MotionLayout Position views Animation Touch Handling State

Slide 11

Slide 11 text

DroidconSF 2019 How?

Slide 12

Slide 12 text

DroidconSF 2019 MotionLayout Transition between states

Slide 13

Slide 13 text

DroidconSF 2019 MotionLayout Transition Start State End State

Slide 14

Slide 14 text

DroidconSF 2019 MotionLayout Transition Start State End State Keyframes

Slide 15

Slide 15 text

DroidconSF 2019 Multiple States State A State B State C State D

Slide 16

Slide 16 text

DroidconSF 2019 Organization xml/ layout/

Slide 17

Slide 17 text

DroidconSF 2019 States Base State MotionLayout States Position with constraints All view attributes Position with constraints Transform view attributes Custom properties Motion attributes (layout file)

Slide 18

Slide 18 text

Constraint Set Motion Layout

Slide 19

Slide 19 text

Transition •OnClick/OnSwipe Integrated touch handling •KeyFrameSet Modify the transition Motion Layout

Slide 20

Slide 20 text

Keyframes KeyPosition KeyAttribute KeyTrigger KeyCycles KeyTimeCycle Motion Layout

Slide 21

Slide 21 text

KeyPosition Motion Layout parentRelative Coordinate Systems

Slide 22

Slide 22 text

KeyPosition Motion Layout deltaRelative Coordinate Systems

Slide 23

Slide 23 text

KeyPosition Motion Layout pathRelative Coordinate Systems

Slide 24

Slide 24 text

KeyCycle Motion Layout Making properties oscillate

Slide 25

Slide 25 text

KeyTimeCycle Motion Layout Oscillate in time

Slide 26

Slide 26 text

DroidconSF 2019 Demo

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

DroidconSF 2019 Where to use it

Slide 29

Slide 29 text

DroidconSF 2019 Integrate with existing components

Slide 30

Slide 30 text

Coordinator Layout + Collapsible Toolbar

Slide 31

Slide 31 text

DrawerLayout

Slide 32

Slide 32 text

ViewPager

Slide 33

Slide 33 text

DroidconSF 2019 Coordinate Views

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

Nested MotionLayout

Slide 36

Slide 36 text

Start End MotionLayout 2 MotionLayout 1 Start End MotionLayout 2 MotionLayout 1

Slide 37

Slide 37 text

DroidconSF 2019 Programmatic Control

Slide 38

Slide 38 text

DroidconSF 2019 RecyclerView

Slide 39

Slide 39 text

RecyclerView + MotionLayout

Slide 40

Slide 40 text

RecyclerView + MotionLayout

Slide 41

Slide 41 text

ConstraintSet set = parentMotion.getConstraintSet(R.id.start); set.clear(R.id.rvItem); set.constrainWidth(R.id.rvItem, getWidth()); set.constrainHeight(R.id.rvItem, getHeight()); int dx = bounds.left - motionBounds.left; int dy = bounds.top - motionBounds.top; set.connect(R.id.rvItem, ConstraintSet.LEFT, ConstraintSet.PARENT_ID, ConstraintSet.LEFT, dx); set.connect(R.id.rvItem, ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP, dy);

Slide 42

Slide 42 text

ConstraintSet set = parentMotion.getConstraintSet(R.id.start); set.clear(R.id.rvItem); set.constrainWidth(R.id.rvItem, getWidth()); set.constrainHeight(R.id.rvItem, getHeight()); int dx = bounds.left - motionBounds.left; int dy = bounds.top - motionBounds.top; set.connect(R.id.rvItem, ConstraintSet.LEFT, ConstraintSet.PARENT_ID, ConstraintSet.LEFT, dx); set.connect(R.id.rvItem, ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP, dy);

Slide 43

Slide 43 text

ConstraintSet set = parentMotion.getConstraintSet(R.id.start); set.clear(R.id.rvItem); set.constrainWidth(R.id.rvItem, getWidth()); set.constrainHeight(R.id.rvItem, getHeight()); int dx = bounds.left - motionBounds.left; int dy = bounds.top - motionBounds.top; set.connect(R.id.rvItem, ConstraintSet.LEFT, ConstraintSet.PARENT_ID, ConstraintSet.LEFT, dx); set.connect(R.id.rvItem, ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP, dy);

Slide 44

Slide 44 text

RecyclerView + MotionLayout

Slide 45

Slide 45 text

Slide 46

Slide 46 text

RecyclerView + MotionLayout

Slide 47

Slide 47 text

Slide 48

Slide 48 text

RecyclerView + MotionLayout

Slide 49

Slide 49 text

DroidconSF 2019 Dynamic Histogram

Slide 50

Slide 50 text

Motion Layout From Code 1. Create a Transition() 2. Create ConstraintSet() x 2 and set on the transition 3. Update ConstraintSets as needed 4. Trigger the MotionLayout animation from the start to end motionLayout.transitionToEnd() Tutorial coming soon!! Dynamically updated histogram

Slide 51

Slide 51 text

DroidconSF 2019 MotionLayout List

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

Start Next Previous

Slide 56

Slide 56 text

if (state == R.id.next) { if (counter < myImgDataset.length -1) { counter++; motionLayout.setProgress(0); updateImages(counter); if (counter < myImgDataset.length - 1) { goNextPosition(); } } else if (counter >= myImgDataset.length - 1) { motionLayout.setProgress(0); } }

Slide 57

Slide 57 text

if (state == R.id.next) { if (counter < myImgDataset.length -1) { counter++; motionLayout.setProgress(0); updateImages(counter); if (counter < myImgDataset.length - 1) { goNextPosition(); } } else if (counter >= myImgDataset.length - 1) { motionLayout.setProgress(0); } }

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

All together…

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

MotionLayout List

Slide 66

Slide 66 text

MotionLayout List

Slide 67

Slide 67 text

DroidconSF 2019 Motion Editor

Slide 68

Slide 68 text

No content

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

No content

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

Overview Panel

Slide 73

Slide 73 text

Overview Panel 1. Creation Icons 2. Overview Graph 2 1

Slide 74

Slide 74 text

Overview Panel + Constraint Set 1. Creation Icons + Transition + Gesture

Slide 75

Slide 75 text

Overview Panel Creation in action

Slide 76

Slide 76 text

Overview Panel 2.Overview Graph

Slide 77

Slide 77 text

Motion Layout Constraint Sets Transition Gesture 2.Overview Graph Overview Panel

Slide 78

Slide 78 text

Overview Panel Motion Layout Constraint Sets Transition Gesture

Slide 79

Slide 79 text

Overview Panel … …

Slide 80

Slide 80 text

... ... ... Overview Panel

Slide 81

Slide 81 text

Overview Panel Overview Graph as State Control Unit

Slide 82

Slide 82 text

Overview Panel

Slide 83

Slide 83 text

No content

Slide 84

Slide 84 text

No content

Slide 85

Slide 85 text

Selection Panel

Slide 86

Slide 86 text

Selection Panel Selection Panel 1. Motion Layout selected 2. Constraint Set selected 3. Transition selected 1 2 3

Slide 87

Slide 87 text

Selection Panel 1. Motion Layout Selected

Slide 88

Slide 88 text

Selection Panel 1. Motion Layout Selected What Component? Properly Constrained?

Slide 89

Slide 89 text

Selection Panel 2.Constraint Set Selected

Slide 90

Slide 90 text

Selection Panel 2.Constraint Set Selected Constrained? Where? What Component?

Slide 91

Slide 91 text

Selection Panel

Slide 92

Slide 92 text

Selection Panel 3.Transition Selected

Slide 93

Slide 93 text

Selection Panel 3.Transition Selected Timeline & Scrubber Animation Toolbar Keyframes + Keyframe

Slide 94

Slide 94 text

No content

Slide 95

Slide 95 text

No content

Slide 96

Slide 96 text

Attributes Panel

Slide 97

Slide 97 text

Attributes Panel Attributes Panel 1. Reflecting Selection 2. Showing Inheritance 3. Authoring Constraints 4.Adding Custom Attributes

Slide 98

Slide 98 text

Attributes panel reflects declared & potential attributes of whatever is selected Attributes Panel 1. Reflecting Selection

Slide 99

Slide 99 text

Inherited Declared Attributes panel reflects inherited v.s. declared attributes with greyed-out & black values 2.Showing Inheritance Attributes Panel

Slide 100

Slide 100 text

Attributes Panel 3.Authoring Constraints

Slide 101

Slide 101 text

No content

Slide 102

Slide 102 text

Attributes Panel 4.Adding Custom Attributes

Slide 103

Slide 103 text

No content

Slide 104

Slide 104 text

DroidconSF 2019 Demo !

Slide 105

Slide 105 text

Andrew Watson @creativedrewy

Slide 106

Slide 106 text

No content

Slide 107

Slide 107 text

No content

Slide 108

Slide 108 text

DroidconSF 2019 Wrap up

Slide 109

Slide 109 text

DroidconSF 2019 Check it out Android Studio 4.0 Canary 4 ConstraintLayout 2.0 Beta 3

Slide 110

Slide 110 text

DroidconSF 2019 Layout Editor Navigation Editor Resource Manager Compose Tooling Multi Preview Layout Inspector Motion Editor Android Studio Design Tools

Slide 111

Slide 111 text

DroidconSF 2019 http://issuetracker.google.com Android Public Tracker > App Development > Jetpack (androidx) > ConstraintLayout > Android Studio > Design Tools > Motion Editor ConstraintLayout component Motion Editor component

Slide 112

Slide 112 text

DroidconSF 2019 ConstraintLayout & MotionLayout Workshop when? where? Android Studio ConstraintLayout 5:10 PM Fisher East 4.0 canary 4 2.0.0-beta3

Slide 113

Slide 113 text

DroidconSF 2019 Thank you! John Hoford @johnhoford Nicolas Roard @camaelon

Slide 114

Slide 114 text

DroidconSF 2019 MotionLayout workshop camaelon.github.io codelabs.developers.google.com/codelabs/ motion-layout