xml - 列表项背景在滚动时发生变化

标签 xml android listview styles

我有一个应用于 ListView 的背景色

<style name="CKButtons">
    <item name="android:windowBackground">@color/window_background</item>
</style>

但每次滚动列表时,背景颜色都会变回系统默认值(黑色)。当滚动停止时,颜色返回到 @color/window_background

样式在AndroidManifest.xml中应用:

<activity android:name=".event.EventList" 
    android:theme="@style/CKButtons"></activity>

我的 ListView 看起来像这样:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   >
<ListView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/android:list"/>
<TextView
    android:id="@+id/android:empty"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:text="@string/eventlist_no_items"/>
</LinearLayout>

如何防止这种情况发生?

最佳答案

您可以在 ListView 上使用属性 android:cacheColorHint 来设置一个 RGB 值,该值应该用作列表项被触摸时的背景色。

有关详细信息,请参阅:http://android-developers.blogspot.com/2009/01/why-is-my-list-black-android.html

关于xml - 列表项背景在滚动时发生变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2416276/

相关文章:

xml - 从 XmlNode 创建 Xdocument 对象

java - 共享操作提供程序对象中的 NullPointerException

android - 处理没有任何java文件的布局资源文件的点击

android - 如何从android中的sdcard获取指定的视频?

android - 如何在 Android 中动态更改 ListView 高度?

android - 从 XML 文件中查找另一个模块中的资源 - Android

excel - VBA - 从 XML 代码循环特定的子节点

android - 顶级 Android Activity

android - 扫描后 ZXing 双像/叠加

Android:了解 OnDrawFrame、FPS 和 VSync (OpenGL ES 2.0)