GridView的行外缘外缘、GridView

2023-09-04 08:08:40 作者:捻碎寂寞的年

我无法找到一个方法来一个外边添加到GridView行。我发现 setHorizo​​ntalSpacing setVerticalSpacing 里面加在GridView行之间的内部填充性,但它并不适用于行的外部边界。

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.

我想有它的特色在谷歌Play商店的结果:

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

谢谢!

推荐答案

您可以使用安卓clipToPadding = FALSE 来添加填充不停留在项目滚动。像这样

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" />

如果你想在滚动条上的填充区域外,设置安卓!scrollbarStyle =outsideOverlay感谢@Karl

 
精彩推荐
图片推荐