Harshid Vasoya
Harshid Vasoya

Reputation: 5721

ListView element background color changes to black while scrolling

I have a listview, when I scroll it, that time listview element background color changes to black. I tried couple of hours, but not getting solution.

I tried

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

or

android:cacheColorHint="#00000000"

Upvotes: 2

Views: 461

Answers (4)

Harshid Vasoya
Harshid Vasoya

Reputation: 5721

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"

Upvotes: 2

Rushabh Patel
Rushabh Patel

Reputation: 3080

You can use this code:

// you can use your color also
android:background="@android:color/transparent"
android:cacheColorHint="@android:color/transparent"

Both color should be same, then your problem will be solved.

Hope it will help you.

Upvotes: 1

Archie.bpgc
Archie.bpgc

Reputation: 24012

set the

android:cacheColorHint

to the color you used as a background to the ListViewItem

Upvotes: 2

Purush Pawar
Purush Pawar

Reputation: 4283

Add following attributes to your listview inside xml layout.

android:scrollingCache="true"
android:cacheColorHint="#ffffff"

Upvotes: 0

Related Questions