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
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
Side Projects
sachag
455
43k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.1k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
The untapped power of vector embeddings
frankvandijk
2
1.8k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
63
55k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.3k
The Invisible Side of Design
smashingmag
301
52k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2.1k
How to Think Like a Performance Engineer
csswizardry
28
2.7k
Abbi's Birthday
coloredviolet
3
8.6k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
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