Loving Lean Layouts
summary
XML view count and hierarchy depth drive measure/layout cost and can cause jank because frames must finish within 16.6 ms for 60 fps. RelativeLayout forces a double-measure pass (nested relatives multiply work), lists with dense item views amplify cost, and dumpsys gfxinfo limits to 120 frames while FrameMetricsListener gives unlimited in-app metrics. Use Hierarchy Viewer/Layout Inspector and systrace to find hotspots; replace extra views with compound drawables or Spannables, try ConstraintLayout to flatten, or write a custom view group — custom drawing fixed a real-world jank case.
AI-written summary · about
