2012-03-13 57 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