-
Notifications
You must be signed in to change notification settings - Fork 175
MotionLayout Performance
John Hoford edited this page Aug 10, 2022
·
1 revision
MotionLayout is a large complex layout that that with care can be used to create highly performant animated UI. In many cases effects are added to the animation till it exceeds the budget and then it is reduced.
There are 3 areas to be concerned about in performance of MotionLayout
- Inflation - Large collections of XML can be expensive to parse.
- Normal Layout - The Multiple ConstraintSets can make Layout more expensive
- Animation - Animation can be the most challenging because it has to hit 30-120fps
MotionLayout can have very complex ConstraintSets that need to be loaded during inflation
When in transition a layout of MotionLayout requires evaluation of the layout of two constraintSets. if in between states it will then need to build up monotonic splines for every object that needs to move.
For smooth animation it requires the screen to be redrawn up to 120 times a second. Rendering complex scenes can prove expensive. Things to watch out for
- Transparency - this requires multiple layers to be completely rendered.
- Shadows - Shadows are computed and can be expensive.
- Changing dimensions of objects. (Strict translation is much cheaper)