Search code examples
javaandroidxmlandroid-gridlayout

How to show a vertical line between columns of a grid layout in android


I am making a native android app, I want to draw a vertical line between two columns in a grid-layout, is there any way i can do this ?? In the following screenshot, you can see the lines between cells and between the column. Basically, i just want to display the grid with my own custom style. This is the link to see the screenshots, apparently stack wont let me post a pic


Solution

  • Add verticalSpacing in your grid layout and set GridView background as the color of line you want.

    <GridView
            android:id="@+id/grid_view"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="#DADADA"
            android:verticalSpacing="1dp"
            android:numColumns="2" />