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
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Scaling GitHub
holman
464
140k
Abbi's Birthday
coloredviolet
2
8.1k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
330
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
160
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
240
Joys of Absence: A Defence of Solitary Play
codingconduct
1
400
Designing for Timeless Needs
cassininazir
1
260
Why Our Code Smells
bkeepers
PRO
340
58k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
150
New Earth Scene 8
popppiees
3
2.3k
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