【问题标题】:scrolling list view color change in androidandroid中的滚动列表视图颜色变化
【发布时间】:2012-09-13 07:11:26
【问题描述】:

滚动时ListView 的颜色有问题。当我滚动 ListView 时,默认情况下,我在分隔线中得到橙色。滚动 ListView 时如何更改分隔线的颜色?谁能帮帮我?...

我的代码是:

<ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:divider="@android:color/transparent"
    android:cacheColorHint="@android:color/transparent"
    android:dividerHeight="5dp"
    android:layout_marginTop="5dp"    >
</ListView>

【问题讨论】:

    标签: android listview colors scroll


    【解决方案1】:

    将此添加到您的 xml 列表视图布局中

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

    【讨论】:

    • 当我们滚动列表视图时,特定的项目分隔符颜色应该改变。
    • 是的。我将分隔线颜色设为透明,即使它仅在滚动列表视图时在分隔线中显示黄色。
    • 如果您使用模拟器进行测试,鼠标滚动时会显示橙色...
    • 这不是错误。它是使用模拟器时的属性。你不必担心。在真实设备上试用。该颜色将不会显示..
    【解决方案2】:
    <ListView
        android:id="@+id/list"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
        android:drawSelectorOnTop="false"
        android:choiceMode="singleChoice"
        android:background="#4a006f"
        android:cacheColorHint="#00000000" />
    

    你必须在ListView:android:cacheColorHint="#00000000"中声明这个标签

    【讨论】:

      【解决方案3】:

      你应该设置 CacheColorHint

      使用这个方法:

      setCacheColorHint(Color.ONE_OF_YOUR_COLORS)。 您无需更改列表项的背景颜色。 你也可以在xml布局中做。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-02-06
        • 1970-01-01
        • 1970-01-01
        • 2013-08-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多