Scrolling a ListView changes everything from White to Black [duplicate]
Solution 1:
The solution is very simple, you also need to set the cache color hint to white: setCacheColorHint(Color.WHITE)
. You don't need to change the list items' background color.
Solution 2:
ListView lv = getListView();
setCacheColorHint(0);
Set the cache color hint to zero.
Solution 3:
Solution is very simple, you also need to set the cache color hint to black in xml.
android:cacheColorHint="#000000"
Solution 4:
Android attempts to improve the performance of ListView scrolling by caching layout information. If you have long scrolling lists of data you should also set the the android:cacheColorHint property on the ListView declaration in the Activity’s AXML definition (to the same color value as your custom row layout’s background). Failure to include this hint could result in a ‘flicker’ as the user scrolls through a list with custom row background colors. So give the same color to the listitem's background and android:cacheColorHint.you can refer below code.
In my Adapter layout I gave as
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ADAPTER_CONTAINER_PRIMARY"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FAFAEE"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:gravity="center">
.....
And in the List view
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/LIST_GRID_LIST_INSTANCES"
android:focusableInTouchMode="true"
android:smoothScrollbar="true"
android:divider="@drawable/Gray"
android:dividerHeight="0.05dp"
android:cacheColorHint="#FAFAEE"
android:background="@drawable/round"/>
Solution 5:
If your ListView
is drawn atop a more complex background -- say, a bitmap or gradient -- then you may need to disable the scroll cache entirely. I ended up setting android:scrollingCache="false"
on my ListView
to resolve this issue.
http://developer.android.com/reference/android/widget/AbsListView.html#attr_android:scrollingCache