Android: Disable highlighting in GridView

前端 未结 8 1310
囚心锁ツ
囚心锁ツ 2020-12-04 11:30

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.

相关标签:
8条回答
  • 2020-12-04 11:36
    <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 :)

    0 讨论(0)
  • 2020-12-04 11:38

    I did the same thing in code using

    GridView.setSelector(new ColorDrawable(Color.TRANSPARENT));
    
    0 讨论(0)
  • 2020-12-04 11:46

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

    0 讨论(0)
  • 2020-12-04 11:50

    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" />
    
    0 讨论(0)
  • 2020-12-04 11:53

    Try It...

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

    0 讨论(0)
  • 2020-12-04 11:54

    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"
    />
    
    0 讨论(0)
提交回复
热议问题