这就是我最后要使用的:spacing = 0 和 layer-list drawable 包含带有圆角的 shapedrawable。另一个这样的可绘制对象用作网格视图的选择器:
padded_border_normal.xml:
<item android:left="3dp"
android:right="3dp"
android:top="3dp"
android:bottom="3dp">
<shape android:shape="rectangle">
<solid android:color="@android:color/transparent" />
<stroke android:color="#8033b5e5" android:width="@dimen/border_width"/>
<corners android:radius="7dp"/>
<size android:height="60dp" android:width="60dp" />
</shape>
</item>
padded_border_pressed.xml:
<item android:left="3dp"
android:right="3dp"
android:top="3dp"
android:bottom="3dp">
<shape android:shape="rectangle">
<solid android:color="#6033b5e5" />
<stroke android:color="#8033b5e5" android:width="@dimen/border_width"/>
<corners android:radius="7dp"/>
<size android:height="60dp" android:width="60dp" />
</shape>
</item>
grid.setSelector(R.drawable.padded_border_pressed);
创建网格和result.setBackgroundResource(R.drawable.padded_border_normal);
创建网格列表视图时