Let’s Sprinkle some #PerfMatters on your ViewGroups
summary
Claim: replacing nested RelativeLayouts with a custom ViewGroup that flattens the hierarchy and implements precise onMeasure/onLayout logic cuts expensive double-measure passes and dramatically reduces jank. Evidence: use systrace and Hierarchy Viewer to find long traversal/draw times, then confirm frame-quality with gfxinfo; on tested devices janky frames drop from ~7–8% toward the 1–2% smooth-scrolling target. Built artifact: an AlbumView that measures with measureChildWithMargins setMeasuredDimension and layouts children directly, and it works.
AI-written summary · about
chapters (10)
- 0:00Start
- 2:11From the Material spec
- 5:49The 16 ms target
- 6:54Let's investigate!
- 7:48Let's zoom in
- 10:10Next step: measure layouting performances
- 12:57Relative Layout
- 14:55What about the other ViewGroups ?
- 17:00A simple example
- 25:36The result
related talks
48mLet's sprinkle some #PerfMatters on our ViewGroups (fr)
42mMeasure. Layout. Draw. Repeat: Custom Views and ViewGroups
35mLoving Lean Layout
41mLoving Lean Layouts
51mMeasure, Layout, Draw, Repeat: Custom Views and ViewGroups
30mIn‑Depth: ViewGroup Layout Internal Implementation
27mView into the abyss
48mEfficient Android Layouts
