How to remove the selected color when dragging through the list

I am showing ListView . When I drag it, the entire ListView is selected with a black background. How to remove this black background?

+7
source share
4 answers

just use in ur xml file inside ListView,

  android:cacheColorHint="@android:color/transparent" 
+15
source

Perhaps because you have your own background for the ListView . When you scroll through them, the entire list is highlighted in black due to its cache color .

Add this piece of code to your ListView and try again:

android:cacheColorHint="#00000000"

+5
source
 view.setBackgroundColor(android.R.color.transparent); 

should be view.setBackgroundResource (android.R.color.transparent) reason setBackgroundColor accepts a hex color value as a parameter.

or

 android:cacheColorHint = "#00000000" 

use this tag for your list. or you can also use

 listview.setCacheColorHint() 

to install it programmatically.

From Why is my list black? Android optimization in the Android developers blog:

To fix this problem, all you have to do is either turn off hint optimization for the cache color if you are using a non-solid background color, or set the hint to the appropriate solid color value. It can be a dome from code, or preferably from XML, using the android: cacheColorHint attribute. To turn off optimization, just use the transparent color # 00000000. The following screenshot shows a list with android: cacheColorHint = "# 00000000" set in the XML layout file:

+3
source

use it

 yourList.setCacheColorHint(Color.WHITE); 
+1
source

All Articles