the_prole
the_prole

Reputation: 8945

How to remove border around grid-view

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

Upvotes: 0

Views: 1482

Answers (2)

Anisuzzaman Babla
Anisuzzaman Babla

Reputation: 7480

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

Upvotes: 0

mdtuyen
mdtuyen

Reputation: 4528

Add:

android:horizontalSpacing="0dp" 
android:verticalSpacing="0dp"

Upvotes: 1

Related Questions