项目中需要给GridView添加一个网格线,而且GridView的背景是一张完整的图片,如图所示:
常用的方法是:
上述的方法直接改变了GridView的背景色,显然是不符合项目要求的,我在网上搜索了一下没有找到解决方案,这里给出自己的解决方案:
给item的布局文件添加一个边框背景即可:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="1dp"
android:color="@android:color/darker_gray" />
</shape>
在Android Studio的Preview中可以很方便的预览到该效果:
原文:http://blog.csdn.net/leoleohan/article/details/50954567