2010-09-23 19 views
3

我已經定義了一個自定義主題,其中我在窗口背景上繪製了一個黑色漸變。我的ListView背景被設置爲透明,但是無論何時滾動,背景顏色變爲黑色,然後滾動停止後,返回漸變顏色。爲什麼是這樣?ListView在滾動時重繪背景顏色

<?xml version="1.0" encoding="utf-8"?> 
    <resources> 
     <!-- Base application theme is the default theme. --> 
     <style name="Theme" parent="android:Theme"> 
     </style> 

     <!-- Variation on our application theme that has a translucent 
    background. --> 
     <style name="Theme.DarkGradient"> 
     <item name="android:windowBackground">@drawable/dark_gradient</item> 

     </style> 

    </resources> 

回答

1

只需設置cacheColorHint =在XML的ListView其透明色 「#00000000」

<ListView android:id="@id/android:list" android:layout_width="320dp" 
android:layout_height="fill_parent" android:layout_centerHorizontal="true" 
android:divider="@color/whitetxtcolor" 
android:layout_weight="2" android:drawSelectorOnTop="false"  
android:layout_below="@id/new_layout" 
android:cacheColorHint="#000000" 
></ListView> 

或U可以這樣做也 this.getListView.setCacheColorHint(0);