Reputation: 275
I want to develop a simple sudoku app. For the layout, I need to have a 9x9 table/grid for the board, and 12 buttons under it and all this must fit in one screen,i had a couple of ideas but there is a problem in each of them
Using GridView
and pass a 2d array to the adapter, BUT, the grid is scrollable and the player must see the whole board.
Using TableView
, but its not clickable as the grid.
Create 81 button for the board in the xml or programmatically, I think it will be complex.
Is there are any other simpler or more efficient ideas! And if not , which one from the above is better.
Upvotes: 0
Views: 186
Reputation: 29285
There's an option for getting this done using weighted width and height. As far as I know this feature is only available in LinearLayout
s.
The main idea I've just explained in this answer.
Please first off read the answer I linked to and then you could use the following approach to laying out your buttons.
Declare a main vertical LinearLayout
and set its width and height to match_parent
.
Add 9 horizontal LinearLayout
s while their width is set to match_parent
and their height set to 0dp
with layout_weigth
equal to 1
.
Add 9 buttons (i.e. your cells) to each LinearLayout
while their width is set to 0dp
and layout_weight
set to 1
and their height is set to match_parent
.
Upvotes: 2