Method example of setting row column split line in Android control GridView

preface

Although aAndroid already has recyclerview, a very powerful view, which can be directly controlled into listview and GridView, and the drawing frame line is more convenient, in many cases, we still have to use GridView to realize the layout. At this time, how can we draw the frame line of gridviw? The following two implementation methods will be provided You can choose

1、 Set the vertical and horizontal spacing through the background color of GridView and item

1. Set GridView background color

2. Set horizontal and vertical spacing: Android: horizontalspacing and Android: verticalspating

3. Set the background color of GridView's item and its selected color

The XML code is as follows

Item layout

2、 Set selector

This method is implemented by setting the Android: background property of the item selector

gv_ Selector code

So far, the two methods have been written. Careful friends may find that the grid line in the middle of the second method is twice thicker than the side line, which is also a deficiency of the second method

summary

The above is the whole content of this article. I hope the content of this article can bring some help to your study or work. If you have any questions, you can leave a message.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>