我在一个 LinearLayout
中有两个 ListView
。 LinearLayout 的背景是可绘制的。一切工作正常,但是当我在任何 ListView 上猛击时,背景图像消失并显示黑色背景。当 fling 停止时,图像再次显示为背景。我不想更改背景,我做错了什么吗?
布局如下:
<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详细信息,感谢 Robinhood。
最佳答案
使用
listView.setCacheColorHint(Color.TRANSPARENT);
在 java 或
android:cacheColorHint="#00000000"
在 xml 中的 ListView 标签内
关于android - ListView后台变化onFling,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9679222/