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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.6k
sira's awesome portfolio website redesign presentation
elsirapls
0
280
4 Signs Your Business is Dying
shpigford
187
22k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
A designer walks into a library…
pauljervisheath
211
24k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
610
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.2k
Ruling the World: When Life Gets Gamed
codingconduct
0
250
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.7k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
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