Background Listview Becomes Black When Scrolling

Background ListView becomes black when scrolling

Add an attribute on the ListView Tag

android:cacheColorHint="#00000000" // setting transparent color

For more details check this blog

My ListView backgrounds go black during scrolling - how to fix?

You will need to use the setCacheColorHint() method of ListView.

Example: list.setCacheColorHint(yourBackColor);

Explanation of the issue and solution here

List color turns black while Scrolling

Add this to listView in the xml file:

android:cacheColorHint="#00000000"

or in Java code:

getListView().setCacheColorHint(0);

Android ListView Background Color Changes on Scroll - colorCacheHint Not Fixing Issue

Could you try setting the cachecolorhint in the xml where the Listview is declared, instead of the LinearLayout :

At layout file, use:

android:cacheColorHint="#0000"

OR at java code,use

listView.setCacheColorHint(Color.TRANSPARENT);

Hope this helps!!

List items becomes black during scroll, setCacheColorHint() takes no effect

In order to make alternate background color for list item . In your adapter class write this line of code

public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
ViewHolder holder;
if (v == null) {
LayoutInflater vi = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.listitem, null);

if (position % 2 == 0) {
v.setBackgroundResource(R.color.firstcolor);
} else {
v.setBackgroundResource(R.color.second color);
}
...............
.........

Hi
For complete help go through my Android Blog hope you will find your answer as you are looking for. Just now i have done from my side and tested, its working fine for me.
At the bottom you will get a link so that you can download full source code.

http://amitandroid.blogspot.in/2013/03/android-listview-with-alternate-list.html

Please let me know if it full fill your requirement.

ListView element background color changes to black while scrolling

In my case this works fine

 <ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="1dip"
android:layout_weight="1"
android:background="#ffffff"
android:choiceMode="singleChoice"
android:cacheColorHint="@android:color/transparent"
android:scrollingCache="false"
android:fastScrollEnabled="true">
</ListView>

One of the developer says, you have to use these 2 properties compulsory..

    android:cacheColorHint="@android:color/transparent"
android:scrollingCache="false"


Related Topics



Leave a reply



Submit