The project needs to add a grid line to the GridView, and the background of the GridView is a complete picture, as shown in the figure:
The common methods are:
1, change the background color of the GridView
2. Set the interval of the GridView horizontal or vertical direction
3 Set the item's layout file background color
The above method directly changed the background color of the GridView, obviously does not meet the requirements of the project, I searched the internet did not find a solution, here to give their own solution :
Add a border background to the item's layout file:
<shape xmlns:android= "http://schemas.android.com/apk/res/android"
android:shape= "Rectangle" >
< Stroke
android:width= "1DP"
android:color= "@android: Color/darker_gray"/>
</shape>
You can easily preview the effect in the preview of Android Studio:
The above is the entire content of this article, I hope to help you learn.