Android: Disable highlighting in GridView

AndroidGridviewClickHighlighting

Android Problem Overview


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.

Android Solutions


Solution 1 - Android

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

Solution 2 - Android

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"
/>

Solution 3 - Android

I did the same thing in code using

GridView.setSelector(new ColorDrawable(Color.TRANSPARENT));

Solution 4 - Android

Add this property to gridview

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

Solution 5 - Android

<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 :)

Solution 6 - Android

Try It...

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

Solution 7 - Android

Just set below property in your XML file.

android:focusableInTouchMode="false"

Solution 8 - Android

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" />

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionImpressionView Question on Stackoverflow
Solution 1 - AndroidCommonsWareView Answer on Stackoverflow
Solution 2 - Androidposit labsView Answer on Stackoverflow
Solution 3 - AndroidMattView Answer on Stackoverflow
Solution 4 - AndroidNayana PriyankaraView Answer on Stackoverflow
Solution 5 - AndroidMohammed SaleemView Answer on Stackoverflow
Solution 6 - AndroidAndroid DevloperView Answer on Stackoverflow
Solution 7 - AndroidRBLView Answer on Stackoverflow
Solution 8 - AndroidPacific P. RegmiView Answer on Stackoverflow