How to set highlight color for ListView item?

You can try to add this: android:drawSelectorOnTop="true" to the definition of the ListView.

Hope this will help you!

P.S. You can optimize your main layout and remove the unnecessary layouts. You can use layoutopt for this.


This is how you do it:

First, in your ListView, put the following:

 android:listSelector="#00000000"

This makes your listSelector (the color you normally see when you click the listview) transparent.

Next, set the LinearLayout of your item layout to this:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/selector"
    android:orientation="horizontal" >

I had the same problem a few days ago and it took me ages to figure this out. Hopefully it works for you!

Tags:

Java

Android