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
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!
If you want result like GooglePlay store, you can set setHorizontalSpacing and setVerticalSpacing and then set layout_margin to GridView.