4

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

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

Normal ListView Normal ListView

Scrolling ListView Scrolling ListView

Pressing ListView item Pressing ListView item

Nouran H
  • 1,992
  • 5
  • 18
  • 24

5 Answers5

3

add a attribute on the ListView Tag

android:cacheColorHint="#00000000"// setting as a transparent color
interboy
  • 856
  • 1
  • 11
  • 25
3
  1. Use the attribute android:cacheColorHint="#000000" in ListView Tag
  2. Regarding make TextView's color black or white, you can refer here to make a custom TextView for your ListView row, The extra work you have to do is just add another attribut inside TextView tag like this

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

Community
  • 1
  • 1
Adil Soomro
  • 37,609
  • 9
  • 103
  • 153
2

This is due because of an optimization. To remove this, just set the cacheColorHint of your listView to transparent, like this: android:cacheColorHint="#00000000"

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

cjk
  • 45,739
  • 9
  • 81
  • 112
AMerle
  • 4,354
  • 1
  • 28
  • 43
0

You can Wrap that ListView inside on LinearLayout having same background and then remove ListView's Background that should work fine. :)

RPB
  • 16,006
  • 16
  • 55
  • 79
  • this is workaround not a solution and i don't think so i should be down Voted for this answer. – RPB Jun 28 '12 at 12:44
0

Please check this answer. I have got the same issue and it is fixed by putting view = null in adapter side.

Community
  • 1
  • 1
Ahmad Arslan
  • 4,498
  • 8
  • 38
  • 59