65

How can I turn off the orange highlight when clicking an item in a GridView?

I haven't been able to find a solution in the documentation or through testing.

Jeremy White
  • 2,818
  • 6
  • 38
  • 74
Impression
  • 781
  • 2
  • 6
  • 7
  • Related: "[Disable Android GridView highlighting completely (disable selection)](http://stackoverflow.com/q/3159897)" if you want to disable not just highlighting but selection and use the GridView just for layout, or handle selection manually via onTouch/Click/etc listeners. – blahdiblah Nov 26 '13 at 23:28

8 Answers8

145

Use android:listSelector="#00000000" in your GridView element in your XML layout file.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • 4
    On listviews android:listSelector="@null" does the trick but on gridview that wont work. But setting it transparent does work =/ – Warpzit Sep 26 '12 at 10:16
  • 1
    Note that elements of the selected view may still change in response to selection (e.g., TextViews changing to their "selected" color state). See [this answer](http://stackoverflow.com/a/3187007/85950) for how to disable selection entirely. – blahdiblah Nov 26 '13 at 23:38
  • 2
    You can use android:listSelector="@android:color/transparent" if you are afraid of numbers – Alysson Myller Jun 20 '14 at 17:53
  • Hi @CommonsWare , can you pls help.. I have a grid view with image as a single item in grid When I m clicking in space left around image ,I get touch feedback from gridview but no feedback on clicking on the image.. what can I do? thanks. – eRaisedToX Jun 13 '17 at 07:07
37

Another option is to reference the transparent color via @android:color/transparent

<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/grid"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:listSelector="@android:color/transparent"
/>
posit labs
  • 8,951
  • 4
  • 36
  • 66
19

I did the same thing in code using

GridView.setSelector(new ColorDrawable(Color.TRANSPARENT));
Kaushik
  • 6,150
  • 5
  • 39
  • 54
Matt
  • 3,837
  • 26
  • 29
11

Add this property to gridview

android:listSelector="@android:color/transparent"
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Nayana Priyankara
  • 1,392
  • 1
  • 18
  • 26
7
<GridView
            android:id="@+id/gridView1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:gravity="center"
            android:horizontalSpacing="10dp"
            android:listSelector="#00000000"
            android:numColumns="3"
            android:scrollbars="none"
            android:stretchMode="columnWidth"
            android:verticalSpacing="10dp" />

Done! this is a solution. thank you :)

Mohammed Saleem
  • 568
  • 5
  • 20
4

Try It...

android:listSelector="@android:color/transparent"

0

Just set below property in your XML file.

android:focusableInTouchMode="false"
RBL
  • 63
  • 2
  • 9
0

Add android:listSelector="#00000000" or android:listSelector="@android:color/transparent" in your GridView XML element like bellow.

<GridView
        android:id="@+id/gridView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:columnWidth="150dp"
        android:gravity="center"
        android:listSelector="#00000000"
        android:numColumns="auto_fit"
        android:stretchMode="columnWidth" />
Pacific P. Regmi
  • 1,607
  • 19
  • 15