2012-03-13 50 views
2

我有兩個ListView s在一個單一的LinearLayout。 LinearLayout的背景是可繪製的。一切工作正常,但當我在任何ListView上投擲時,背景圖像消失並顯示黑色背景。當停止時,圖像再次顯示爲背景。我不想改變背景,我是否做錯了什麼?ListView背景變化onFling

佈局是如下:

<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     > 
    <TextView 
     android:text="Upcoming Trips" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/top_blue_box" 
     android:textColor="#ffffff" 
     android:textStyle="bold" 
     android:textSize="16sp" 
     android:layout_gravity="center" 
     /> 
    <ListView 
     android:id="@+id/upList" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 

     android:layout_gravity="center_vertical" 
     android:layout_weight="2"   
     /> 
    <TextView 
     android:text="Past Trips" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/bottom_box" 
     android:textColor="#ffffff" 
     android:textStyle="bold" 
     android:textSize="16sp" 
     android:layout_gravity="center_horizontal" 
     /> 
    <ListView 
     android:id="@+id/downList" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 

     android:layout_gravity="center_vertical" 
     android:layout_weight="2"   
     /> 
    </LinearLayout> 

編輯: 的解決方案是在細節解釋here,由於羅賓漢。

回答

4

使用

listView.setCacheColorHint(Color.TRANSPARENT); 

在Java或

android:cacheColorHint="#00000000" 

的ListView標籤內的XML

+1

謝謝,它的工作:) – noob 2012-03-13 06:30:28

2

應用相同的顏色緩存暗示的ListView作爲佈局的顏色。

實施例:

android:cacheColorHint="light blue" 

Cache Color Hint

+1

這一個工作太,日Thnx(需要使用顏色代碼);) – noob 2012-03-13 06:31:00