Horizontal and Vertical line inside Gridview

  • Replies:1
  • OpenNot stickiedUnanswered
  • Forum posts: 10

Jun 29, 2019, 9:35:50 AM via Website

Hai,

   I have binded Gridview using ArrayAdapter.I need to show horizontal lines between rows and vertical lines between columns.How to show these lines in gridview?Below is my Code:

ArrayList arrayList = db.getAllStudent();
simpleList = (GridView) findViewById(R.id.simpleListView);

    ArrayAdapter<String> arrayAdapter =new ArrayAdapter<>(this,android.R.layout.simple_list_item_1,arrayList);
    simpleList.setAdapter(arrayAdapter);
Reply
  • Forum posts: 109

Jul 1, 2019, 8:16:07 AM via Website

For showing verticle and horizontal lines in a GridView, you can set the properties android:verticalSpacing and android:horizontalSpacing with 2dp or 1dp whichever is your need in the XML file.

<GridView android:id="@+id/grid_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:numColumns="auto_fit"
        android:layout_margin="5dp"
        android:verticalSpacing="2dp"
        android:horizontalSpacing="2dp" />
Helpful?
Reply