List background Item changes to scroll

I have a background color applied to a ListView

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

but every time the list scrolls, the background color changes back to the system default (black). When scrolling stops, the color returns to @color/window_background .

The style is applied in AndroidManifest.xml :

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

and my ListView looks like this:

 <?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> 

How can I prevent this?

+4
source share
2 answers

I already understood it myself

 <style name="CKButtons"> <item name="android:windowBackground">@color/window_background</item> <item name="android:listViewStyle">@style/CKListview</item> </style> <style name="CKListview" parent="android:style/Widget.ListView"> <item name="android:cacheColorHint">@color/window_background</item> </style> 

thanks.

+1
source

You can use the android:cacheColorHint on your ListView to set the RGB value, which should be used as the background color for the list item when it is touched.

See http://android-developers.blogspot.com/2009/01/why-is-my-list-black-android.html for details

+2
source

Source: https://habr.com/ru/post/1303653/


All Articles