Android: Disable highlighting in GridView

纵然是瞬间 提交于 2019-11-27 17:26:08

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

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

I did the same thing in code using

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

Add this property to gridview

android:listSelector="@android:color/transparent"
<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 :)

Try It...

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

Just set below property in your XML file.

android:focusableInTouchMode="false"

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" />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!