0

I want a gridview with empty grid lines as follows

Gridlines in Empty Cells

Here is what i got till now, gridview with gridlines in the occupied cells only. I want gridlines in empty cells also. Is this possible?

Gridline in Occupied Cells

sooraj.e
  • 766
  • 2
  • 11
  • 26

2 Answers2

1

I'm almost positive a GridView was never intended for this, so you have two options.

-Write your own GridView that supports a defaulted view.

OR

-If this is not a dynamic view that is changing all the time in real time:

  1. In your adapter, set a minimum in your getCount method (return Math.max(actualSize, minimumCount)). And set the views with no data to your empty boxes.

  2. Make sure the count is always some mod of 4 to ensure each row will be filled beyond that.

That's just what I'm coming up with on the top of my head, there's most likely a better way to do it, but hopefully I'm moving you in the right direction.

Brandon Romano
  • 1,022
  • 1
  • 13
  • 21
  • @Romano thanks man, i had the second option in my mind. However i just want to know if there is any other way. – sooraj.e Apr 29 '13 at 05:15
0

Try putting an empy View within the empty cells of the grid. For example, use a TextView with no text, or simply a new View().

tbkn23
  • 5,205
  • 8
  • 26
  • 46