问题
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