Android Overdraw: Stop Painting Pixels Twice

Overdraw is wasted GPU work, painting the same pixel multiple times in one frame. It causes UI stutter and drains battery. Fix it by removing unneeded backgrounds and flattening your UI layouts.
WHY IT EXISTS To maintain a smooth user experience, an app needs to render frames in under 16ms. The GPU has a finite budget of work it can do in that time. Overdraw is the process of drawing the same pixel multiple times in a single frame, consuming this budget for no visible benefit, which can lead to dropped frames (jank) and increased battery usage.
THE MENTAL MODEL Think of painting a room. You would not apply a coat of blue paint to a wall, let it dry, and then immediately paint over it with a coat of white. You would just paint it white from the start. Overdraw is the GPU painting that unnecessary blue layer that no one will ever see, wasting time and paint.
HOW IT WORKS The Android system draws your UI from back to front based on the view hierarchy. If a parent layout has a white background and a child view on top also has a white background, the GPU first paints the pixels for the parent, then paints the exact same pixels again for the child. The "Debug GPU overdraw" developer option visualizes this by color-coding areas: blue for 2x overdraw, green for 3x, and red for 4x or more. Your goal is to minimize or eliminate red areas.
WHEN TO USE IT Optimize for overdraw when you observe UI jank, especially during scrolling or animations. It's a primary optimization target for lists in a RecyclerView, complex custom views, or screens with many overlapping UI elements. Prioritize fixing overdraw on performance-critical screens and on devices with less powerful GPUs.
WHEN NOT TO USE IT Do not obsess over eliminating every single instance of 2x (blue) overdraw, as it's often unavoidable and has a negligible performance impact. Aggressively removing backgrounds can break UI functionality; for example, a view might need its background for touch feedback (ripples) or to be visible when it has no content. Focus your efforts on the 4x+ (red) areas where the performance cost is highest.
ONE CANONICAL EXAMPLE A common source of overdraw is a RecyclerView where both the list itself and each list item have an opaque background. If the RecyclerView has a white background and each list item also has a white background, every item pixel is drawn twice. The fix is to set the RecyclerView's background to white, but set the root view of each list item's layout to have a transparent background (@android:color/transparent). The pixels are then painted only once by the parent RecyclerView.
Read the original → developer.android.com
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.