Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

So I'm using a custom listview through an adapter, and on my Nexus 7 everything looks great, but on my HTC Incredible 2 I'm running into an issue where my background color changes. Here's my XML file with the cacheColorHint set. I've also tried with #AA00000. Any suggestions? I also tried setting it in the activity via setCacheColorHint, but nothing's working yet.

 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="horizontal"     
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:padding="10dp"
 android:background="#AA000000"
 android:cacheColorHint="#00000000">

 <ImageView android:id="@+id/ExhibitListIcon"
 android:contentDescription="Exhibit List Icon"
 android:layout_width="wrap_content"
 android:layout_height="fill_parent"
 android:gravity="center_vertical"
 android:layout_marginRight="15dp"
 android:layout_marginTop="5dp"
 android:layout_marginBottom="5dp" />

 <TextView android:id="@+id/ExhibitListTitle"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:gravity="center"
 android:textStyle="bold"
 android:textSize="22dp"
 android:textColor="#FFFFFF"
 android:layout_marginTop="5dp"
 android:layout_marginBottom="5dp" />

 </LinearLayout>
like image 584
Paul Ruiz Avatar asked Dec 02 '12 20:12

Paul Ruiz


3 Answers

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!!

like image 127
Abhishek Sabbarwal Avatar answered Nov 14 '22 19:11

Abhishek Sabbarwal


Add below line to your listview:

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

like image 33
Mukesh Parmar Avatar answered Nov 14 '22 19:11

Mukesh Parmar


listView.setCacheColorHint(Color.TRANSPARENT);
like image 2
farhad.kargaran Avatar answered Nov 14 '22 18:11

farhad.kargaran