Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GridView rows outer margin

I cannot find out a way to add an outer margin to the GridView rows. I found the setHorizontalSpacing and setVerticalSpacing properties which add inner padding between the GridView rows, however it doesn't apply to the outer borders of the rows.

I'd like to have a result as it's featured on the Google Play store:

enter image description here

Thanks!

like image 600
Diego Acosta Avatar asked Jun 17 '13 00:06

Diego Acosta


1 Answers

You can use android:clipToPadding=false to add padding that doesn't stay when the items are scrolled. Like this

<GridView     android:id="@+id/grid"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:horizontalSpacing="16dp"     android:verticalSpacing="16dp"     android:padding="16dp"     android:clipToPadding="false" /> 

And if you want the scrollbar on the outside of the padding area, set android:scrollbarStyle="outsideOverlay" thanks @Karl!

like image 156
Cameron Ketcham Avatar answered Sep 27 '22 21:09

Cameron Ketcham