yiranwujixian 2012-09-17 07:21 采纳率: 100%
浏览 3088
已采纳

当移动滚动条时,ListView背景变黑

我已经创建了一个特殊的List,它包含了下边这些元素用来创建一个可以滚动的列表,这个列表的左侧的每一行包含一个图片,右侧包含一些文本:
从“root”布局开始

<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中,我放置了下边的"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>

只要屏幕是静态的(没有滚动),它能够正确显示,但是当我开始通过背景的row-item(在代码中,一个“icon”能够显示出来)列表滚动的时候,它能够显示,但是背景的“root”布局将成为全黑...大多数时候,当滚动条停止的时候背景又将回到原来的颜色...当我测试的时候,我还在root-element添加了一个带有相同背景的TextView,当List滚动的时候,这将保留它的颜色...有人能解释为什么会发生这样的情况吗,怎么解决?

  • 写回答

2条回答 默认 最新

  • 鹳狸媛 2012-09-17 07:45
    关注

    在ListView Tag增加一个属性

    android:cacheColorHint="#00000000"
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器