Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Listview background image shows on each row, why?

I have a ListActivity with a ListView and everything works great; however I am trying to set a background image and the image is appearing in each row and making the row very tall.

How do I make the background for that view so the rows don't pick up the image?

like image 790
tracy Avatar asked Dec 16 '22 17:12

tracy


1 Answers

In onCreate() of your ListActivity, call

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

Without the .setCacheColorHint(0) the background will flash to the original background color every time you scroll. With it added the background is a constant. (Thanks Matt it fixed that issue for me).

like image 196
Matt Avatar answered Dec 19 '22 06:12

Matt