Android: ListView xml layout doesn't show background image when scrolling

I have an Activity with a ListView, I set the background image to the view programmatically. When I look through my list, the background image turns white (because my theme is Theme.Light.NoTitleBar).

  • How can I make it scroll the blue background?
  • If the above point works, how can I change the color of the text of the ListView to white instead of black?

Plain ListView Normal listview

Scrolling ListView Scrolling listview

Click ListView Pressing ListView item

+4
source share
5 answers
  • Use the android:cacheColorHint="#000000" attribute android:cacheColorHint="#000000" in the ListView tag
  • As for the TextView's color in black or white, you can here to create a custom TextView for your ListView string, the extra work you have to do is just add another attribute inside the TextView tag, like this

    android:textColor="#FFF" //or #FFFFFF for white

+3
source

add attribute to ListView tag

 android:cacheColorHint="#00000000"// setting as a transparent color 
+3
source

This is due to optimization. To remove this, simply set the cacheColorHint of your listView as transparent, for example: android:cacheColorHint="#00000000"

Full post here: http://android-developers.blogspot.fr/2009/01/why-is-my-list-black-android.html

+2
source

You can wrap this ListView inside a LinearLayout with the same background, and then remove the ListView Background , which should work fine. :)

0
source

Please check this answer. I have the same problem and fixed it by putting view = null towards the adapter.

0
source

All Articles