0

Here is my grid view layout where I have tried to use android:listSelector="@null"

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#191919">

        <GridView
            android:id="@+id/gridView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:columnWidth="100dp"
            android:drawSelectorOnTop="true"
            android:gravity="center"
            android:numColumns="auto_fit"
            android:stretchMode="columnWidth"
            android:verticalSpacing="5dp"
            android:focusable="true"
            android:clickable="true"
            android:listSelector="@null"/>

    </RelativeLayout>

But I can't get rid of these black borders in my grid-view

enter image description here

the_prole
  • 8,275
  • 16
  • 78
  • 163

2 Answers2

1

Add:

android:horizontalSpacing="0dp" 
android:verticalSpacing="0dp"
mdtuyen
  • 4,470
  • 5
  • 28
  • 50
0

You can change it using: android:listSelector.

You can try removing the selector with android:listSelector="@null

<!-- Setting the listSelector to null removes the 5px border -->
<GridView
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:listSelector="@null" />

If it doesn't work add android:fadingEdgeLength="0px" to your GridView

<GridView
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fadingEdgeLength="0px"
android:listSelector="@null" />

Or, in Java:

GridView.setFadingEdgeLength(0);
Anisuzzaman Babla
  • 6,510
  • 7
  • 36
  • 53