The Importance of Measure
summary
Explains how Android runs a top‑down measure then layout then draw, why onMeasure must call setMeasuredDimension, and how MeasureSpec modes (UNSPECIFIED, EXACTLY, AT_MOST) and resolveSize determine final size. Shows a custom 500×500 dp view that still gets clipped inside a 200×200 parent, notes measurement can be invoked four times in tricky cases and must finish within 16 ms, and gives concrete fixes for padding, text sizing, and a ViewPager height workaround (measure children with UNSPECIFIED and use the max).
AI-written summary · about
chapters (13)
- 0:00Introduction to measurement
- 1:10Android layout phases
- 2:36Parent-child measurement process
- 5:05Understanding measure specs
- 6:32Breaking measure rules demo
- 8:38Measure spec quiz examples
- 14:57Using MeasureSpec class
- 17:01Proper measurement techniques
- 18:23Accounting for padding
- 20:11Measuring content correctly
- 21:56ViewGroup measurement tips
- 22:18Custom ViewPager example
- 25:51Summary and resources
related talks
42mMeasure. Layout. Draw. Repeat: Custom Views and ViewGroups
51mMeasure, Layout, Draw, Repeat: Custom Views and ViewGroups
35mMake It Fit, how Android measures and draws views
40mWriting Custom Views for Android
32mDeep dive into size configuration changes
30mIn‑Depth: ViewGroup Layout Internal Implementation
45mSize Matters: How to Measure and Reduce Android App Weight
30mLet’s Sprinkle some #PerfMatters on your ViewGroups
