Skip to content Skip to sidebar Skip to footer

How To Remove Horizontal Spacing Between The Grid View In Android?

I need to draw lines between the Grid items horizontally . I achieved but the problem is space between the grid items It is not connecting between the items instead of that it pu

Solution 1:

Try this

   <GridView xmlns:android="http://schemas.android.com/apk/res/android" 
        android:id="@+id/gridview"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
        android:columnWidth="14dp"
        android:numColumns="auto_fit"
        android:verticalSpacing="10dp"
        android:horizontalSpacing="10dp"
        android:stretchMode="columnWidth"
        android:gravity="center"
    />

Solution 2:

use:

android:stretchMode="columnWidth"

in your Gridview:

<GridView
    android:id="@+id/calendar_home"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/container"
    android:horizontalSpacing="0dp"  //add this also
    android:numColumns="7"
    android:overScrollMode="never"
    android:scrollbars="none"
    android:stretchMode="columnWidth" />

Also for the lines to be connected use:

  <View
        android:id="@+id/view_line"
        android:layout_width="match_parent"  //change here
        android:layout_height="2dp"
        android:layout_marginTop="20dp"
        android:layout_toRightOf="@+id/img_exercise"
        android:background="@color/color_black" />

Post a Comment for "How To Remove Horizontal Spacing Between The Grid View In Android?"