我有一个应用于 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/