Background ListView becomes black when scrolling
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
When an Android ListView turns black while scrolling, the cause is usually not the data source. It is typically a drawing issue related to transparent backgrounds, recycled row views, or an old ListView caching behavior where the scroll cache color defaults to black.
The Classic Cause: cacheColorHint
On older Android versions, ListView used a drawing cache during scrolling. If the list background was transparent or not explicitly styled, the cache could render as black while rows were moving.
The classic XML fix was:
That tells the scroll cache not to paint the old default black hint.
If you are maintaining legacy UI code, this property is still the first thing to check because it directly matches the visual symptom.
Also Set a Real Background
A transparent list on top of a parent that is not painting what you expect can also look black while scrolling. Give the list and sometimes the row layout an explicit background.
And for row layouts:
This prevents recycled rows from temporarily exposing an unwanted background beneath them.
Recycled Views Must Be Fully Reset
If your adapter reuses convertView, every property that can vary by row must be reset every time. Otherwise a recycled row may briefly carry stale visual state from an earlier item.
If some rows are transparent, highlighted, or alpha-modified, those properties must also be restored explicitly. Black flashes are often just a symptom of incomplete state reset during view recycling.
Theme and Parent Layout Interactions
The list may not be the only component involved. Black backgrounds can also come from:
- a parent layout using a dark default window background
- a selector or pressed-state drawable with unexpected transparency
- an image-backed container that is not redrawn as expected
That is why a "fix" in the adapter sometimes appears to work on one device and fail on another. The actual problem may be the combination of row background, list background, selector, and theme.
Modern Perspective
If you are working on new Android code, RecyclerView is usually preferred over ListView. But the underlying lesson is the same:
- set explicit backgrounds
- avoid ambiguous transparency
- reset recycled view state completely
The old cacheColorHint property is mostly a legacy ListView detail, but many black-scroll artifacts in older apps still trace back to it.
Common Pitfalls
- Leaving the
ListViewbackground transparent and assuming the parent view will always paint the right color during scrolling. - Forgetting
android:cacheColorHint="@android:color/transparent"in legacyListViewcode where the cached scroll background defaults to black. - Reusing
convertViewwithout resetting all row-specific visual properties such as background, alpha, or pressed state. - Debugging only the adapter while ignoring parent layout backgrounds, selectors, and theme defaults.
- Treating the issue as a data problem when it is really a rendering and view-state problem.
Summary
- A black
ListViewbackground during scrolling is usually a rendering or styling issue, not a data issue. - In legacy Android code,
cacheColorHintis a common direct fix. - Explicit list and row backgrounds make the drawing behavior more predictable.
- Recycled views must be fully reset in
getView. - If you are building new UI, prefer
RecyclerView, but the same background and reuse principles still apply.

