Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
MotionLayout : Animation Magic
Search
Thomas Kioko
October 05, 2018
160
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
MotionLayout : Animation Magic
Thomas Kioko
October 05, 2018
Featured
See All Featured
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.4k
Speed Design
sergeychernyshev
33
2k
Agile that works and the tools we love
rasmusluckow
331
22k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
610
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Building the Perfect Custom Keyboard
takai
2
840
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
3
430
Ruling the World: When Life Gets Gamed
codingconduct
0
300
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
270
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
440
Transcript
MotionLayout @code_wizard https:/ /github/kioko https:/ /thomaskioko.com Thomas Kioko Android Engineer
Constraint Layout 2.0
BUT FIRST …
AbsoluteLayout FrameLayout RelativeLayout CoordinatedLayout … LinearLayout Take me Back
Other Layouts R.I.P
Constraint 1.1
Chains Circular Constraints Helpers Barries ConstraintLayout 1.1
ConstraintLayout 2.0
There’s more …
ConstraintLayout 2.0
Will I be able to control robots? 2.0… Why?
Will it take me to the moon? 2.0… Why?
“ “ “ “ MotionLayout
Bring your UI back from the dead Animations
ConstraintSet Constraint MotionScene Events Transition KeyFrames Key Concepts
Let’s Cook Some Code
Gradle Dependency dependencies{ … implementation 'androidx.constraintlayout:constraintlayout: 2.0.0-alpha2' }
- Improvments on Support Library - Backward compatibility. Btw …
AndroidX released with JetPack
The UI
A few minutes later…. …..
Movie UI -1- Define The Layouts
activity_movie_detail.xml <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/motion_layout_movie_detail” … > … </androidx.constraintlayout.widget.ConstraintLayout >
Let’s dance -2- Switch to MotionLayout
activity_movie_detail.xml <androidx.constraintlayout.motion.widget.MotionLayout android:id="@+id/motion_layout_movie_detail” … > … </androidx.constraintlayout.motion.widget.MotionLayout>
xml/ scene_movie.xml <MotionScene … > </MotionScene> -3- Define TheScene
- Start: constraintSetStart - End: constraintSetEnd ConstraintSets 2 States Types
xml/ scene_movie.xml <MotionScene … > <ConstraintSet android:id=“@+id/start”> … </ConstraintSet> <ConstraintSet
android:id=“@+id/end”> … </ConstraintSet> </MotionScene> -4- Add ConstraintSet
xml/ scene_movie.xml <MotionScene … > <Transition app:constraintSetEnd="@id/end" app:constraintSetStart="@id/start”> </Transition> …..
</MotionScene> -5- Add Transition
Reusing Constraints .Have the same Id as the widgets. .
Rewrite Constraints Constraint
xml/ scene_movie.xml <MotionScene … > <Transition … </Transition> <Constraint app:constraintSetStart="@id/start”>
<Constraint android:id="@+id/iv_backdrop" android:layout_width="wrap_content" android:layout_height=“280dp” app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> </Constraint> </MotionScene> -6- Add Constraint Start
xml/ scene_movie.xml <MotionScene … > <Transition … </Transition> <Constraint app:constraintSetStart="@id/end”>
<Constraint android:id="@+id/iv_backdrop" android:layout_width="wrap_content" android:layout_height=“30dp” app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> </Constraint> </MotionScene> -7- Add Constraint End
xml/ scene_movie.xml -8- Add Other Constraints
.onClick The Trigger . onSwipe Transition Events
xml/scene_movie.xml <MotionScene … > <Tranision> <OnSwipe app:dragDirection="dragUp" app:touchAnchorId="@id/recycler_view_episodes" app:touchAnchorSide=“top” />
</Transition> </MotionScene> -9- Add Event
Prepare for Landing
Let’s up MotionScene & the Layout -10- Last Line (I
Think ..)
layout/movie_detail_activity.xml -11- Add Event <androidx.constraintlayout.motion.widget.MotionLayout android:id="@+id/motion_layout_movie_detail” app:layoutDescription="@xml/scene_movie_detail” … > …
</androidx.constraintlayout.motion.widget.MotionLayout>
…
None
The End
CustomAttributes . Position KeyFrames . KeyTimeCycle . What Next? MotionLayout
Editor .
@code_wizard The End. https://github.com/kioko https://thomaskioko.com