Grid-lines on a GridView

家住魔仙堡 提交于 2019-12-13 16:51:20

问题


How do I define grid-lines for a GridView? Is there an attribute or do I have to draw my own background with them in it?


回答1:


There is no such attribute. The easiest thing is to create a subclass of GridView and override dispatchDraw() or onDraw() to do it yourself.




回答2:


set the background to the view(inflate layout) inside the GridView so that gridview display the line automatically.




回答3:


You can just set a padding for each cell of the grid view so that that looks like the grid line. Each cell say would be made up of a linear layout.

Another way of doing this would be to have the cell as a linearlayout and have a view inside that with width of say 0.5dp and height as mp and vice-versa for the horizontal line.



来源:https://stackoverflow.com/questions/6010311/grid-lines-on-a-gridview

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!