2012-12-02 55 views
5

所以我通過一個適配器使用自定義列表視圖,並且在我的Nexus 7上一切看起來都很棒,但是在我的HTC Incredible 2上我遇到了一個問題,我的背景顏色改變了。這是我用cacheColorHint設置的XML文件。我也嘗試過#AA00000。有什麼建議麼?我也嘗試通過setCacheColorHint在活動中設置它,但沒有任何工作。Android ListView滾動顏色變化 - colorCacheHint沒有修復問題

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

回答

21

你能嘗試設置cachecolorhint在列表視圖中聲明的XML,而不是的LinearLayout:

在佈局文件,使用:

android:cacheColorHint="#0000" 

或Java代碼,使用

listView.setCacheColorHint(Color.TRANSPARENT); 

希望這有助於!

+0

這做到了!非常感謝你。 –

+0

很高興我可以幫助....你可以接受這個答案,如果它的作品:) –

+0

完成並完成。再次感謝。 –

2
listView.setCacheColorHint(Color.TRANSPARENT); 
6

添加下面一行到你的列表視圖:

機器人:cacheColorHint = 「@安卓:彩色/透明」