简体   繁体   English

滚动时ListView元素的背景颜色变为黑色

[英]ListView element background color changes to black while scrolling

I have a listview , when I scroll it, that time listview element background color changes to black. 我有一个listview ,当我滚动它时,那个listview元素的背景颜色变为黑色。 I tried couple of hours, but not getting solution. 我尝试了几个小时,但没有得到解决。

I tried 我试过了

android:cacheColorHint="@android:color/transparent"

or 要么

android:cacheColorHint="#00000000"

set the 设置

android:cacheColorHint

to the color you used as a background to the ListViewItem 变为您用作ListViewItem背景的颜色

In my case this works fine 就我而言,这很好

 <ListView
    android:id="@+id/list"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_margin="1dip"
    android:layout_weight="1"
    android:background="#ffffff"
    android:choiceMode="singleChoice" 
    android:cacheColorHint="@android:color/transparent"
    android:scrollingCache="false"
    android:fastScrollEnabled="true">
</ListView>

One of the developer says, you have to use these 2 properties compulsory.. 一位开发人员说,您必须强制使用这两个属性。

    android:cacheColorHint="@android:color/transparent"
    android:scrollingCache="false"

You can use this code: 您可以使用以下代码:

// you can use your color also
android:background="@android:color/transparent"
android:cacheColorHint="@android:color/transparent"

Both color should be same, then your problem will be solved. 两种颜色应该相同,那么您的问题将得到解决。

Hope it will help you. 希望对您有帮助。

Add following attributes to your listview inside xml layout. 在xml布局内的列表视图中添加以下属性。

android:scrollingCache="true"
android:cacheColorHint="#ffffff"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM