Skip to content Skip to sidebar Skip to footer

How To Give Single Line Border To Gridview Android

I have created gridview with customer adapter. To give each cell border, I have placed them in two layouts. The first layout has black bg and second layout has white bg and content

Solution 1:

You should do the next:

  • set background color of your gridview it will be a border color
  • set background color of your grid item as you need
  • set vertical and horizontal spacing it will be a border thickness

And don't forget to change you grid item layout height as match_parent

GridViewgv= findViewById(R.id.my_grid_view);
gv.setBackgroundColor(Color.WHITE);
gv.setVerticalSpacing(1);
gv.setHorizontalSpacing(1);

Post a Comment for "How To Give Single Line Border To Gridview Android"