Android recyclerview realizes horizontal and vertical split lines

Android recyclerview does not arbitrarily set the horizontal split line like listview in the past. If you want to realize the horizontal / vertical split line of recyclerview, you need to inherit from recyclerview.itemdecoration and override getitemoffsets method to increase the horizontal / vertical split line.

Write an example.

MainActivity.Java:

The layout file is very simple. Put a recyclerview and pay attention to the setting of background color:

The most critical recyclerviewitemdecoration.java:

Code run result:

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

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
分享
二维码
< <上一篇
下一篇>>