Android Listview wallpaper is displayed on every line, why?

I have a ListActivity with a ListView, and everything works fine; however, I am trying to set a background image and the image appears on each line and makes the line very tall.

How to create a background for this view so that the lines do not display the image?

+4
source share
2 answers

In onCreate () of your ListActivity call

getListView().setCacheColorHint(0); getListView().setBackgroundResource(R.drawable.backgroundresource); 

Without .setCacheColorHint (0), the background will blink in front of the original background color each time it scrolls. With its addition, the background is a constant. (Thanks Matt, he fixed this problem for me).

+11
source

perhaps you are attaching a background to a list item, be sure to do it in your ListActivity:

 getListView().setBackgroundResource(...) 
+1
source

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


All Articles