滚动时背景的ListView变黑 [英] Background ListView becomes black when scrolling
问题描述
我已经创建了它存在了以下元素,创造一个滚动列表每包含在左侧图像和右侧一些文本行中的具体名单:
I have created a specific List which exists out of the following elements to create a scrollable list with every row containing a Image on the left side and some text on the right side:
要以一个根的布局:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#C8C8C8"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="false"
android:divider="#C8C8C8"
android:background="#C8C8C8"/>
,然后在ListView我把下面的行项目中:
and then within the ListView I place the following "row" item :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/bg_row"
>
<ImageView
android:layout_width="wrap_content"
android:paddingLeft="10px"
android:paddingRight="15px"
android:paddingTop="5px"
android:paddingBottom="5px"
android:layout_height="wrap_content"
android:src="@drawable/bg_image"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="5px"
android:paddingBottom="5px"
android:textSize="16sp"
android:textColor="#000000"
android:layout_gravity="center"
android:maxHeight="50px"/>
</LinearLayout>
只要屏幕是静态显示(如在无运动)它将正确显示出来,但是,当我开始通过列表中的行项目(一个图标的背景的滚动如可以在$显示C $ C)会正确显示,但可以的根布局的背景将变成全黑的......当滚动停止后台将大部分的时间,找回它的颜色......
当我测试我还添加了一个的TextView
在根元素具有相同的背景,这一次将其扣留的颜色,当列表滚动...
任何想法,为什么这种情况正在发生,以及如何解决此问题?
As long as the screen is shown statically (as in no movement) it will be shown correctly, but when I start scrolling through the list the background of the row-item (an "icon" as can be shown in the code) will be shown correctly but the background of the "root" layout will become completely black... when the scrolling stops the background will, most of the times, get back its color...
As I test I also added a TextView
in that root-element with the same background, this one will detain it's color when the List is scrolled...
Any idea why this is happening, and how to solve this?
推荐答案
添加一个属性上的ListView标签
Add an attribute on the ListView Tag
android:cacheColorHint="#00000000" // setting transparent color
有关详细信息检查这个博客
这篇关于滚动时背景的ListView变黑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!