GridView rows outer margin

后端 未结 2 2002
無奈伤痛
無奈伤痛 2021-01-30 09:30

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

相关标签:
2条回答
  • 2021-01-30 09:34

    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!

    0 讨论(0)
  • 2021-01-30 09:36

    If you want result like GooglePlay store, you can set setHorizontalSpacing and setVerticalSpacing and then set layout_margin to GridView.

    0 讨论(0)
提交回复
热议问题