Search code examples
androidlayoutgridcell

android - grid or cells?


I'm just trying to make a 20x20 Grid. The Grids are big, e.g. one grid is 100dp (width and height). When you start the app you see only a few grids. You cannot see the rest of the grids. They are out of the screen. When you touch with your finger one of the grids, you can scroll to left or right or top or bottom. When you double touch on one grid you can Enter a text.

For example 9x6 Grid (The whole Xs are the smartphone Screen) What you first see.

_______________________________________________________
|     |     |     |     |     |     |     |     |     |
|     |     |     |     |     |     |     |     |     |
-------------------------------------------------------
|     |     |     |     |     |     |     |     |     |
|     |     |     |     |     |     |     |     |     |
------------XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX------------
|     |     X     |     |     |     |     X     |     |
|     |     X     |     |     |     |     X     |     |
------------X-----------------------------X-------------
|     |     X     |     |     |     |     X     |     |
|     |     X     |     |     |     |     X     |     |
------------XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX------------
|     |     |     |     |     |     |     |     |     |
|     |     |     |     |     |     |     |     |     |
-------------------------------------------------------
|     |     |     |     |     |     |     |     |     |
|     |     |     |     |     |     |     |     |     |
-------------------------------------------------------

I started to programming with Grid View and Adapter. But with no success. What is the best way? I mean, the Grid can be 100x100. After I haven't success with Grid view, i started to look some tutorials with drawing, but I think, I'm on the wrong way?


Solution

  • Try setting the android:numColumns property to the number of columns you want. The GridView should set the number of rows to whatever it takes to display all the cells.

    Then, wrap the GridView inside a HorizontalScrollView so the user can scroll left and right. The GridView will handle the vertical scrolling.