Ahmed Bassiouny
Ahmed Bassiouny

Reputation: 275

Android sudokod layout

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

  1. Using GridView and pass a 2d array to the adapter, BUT, the grid is scrollable and the player must see the whole board.

  2. Using TableView, but its not clickable as the grid.

  3. 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

Answers (1)

frogatto
frogatto

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 LinearLayouts.

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.

  1. Declare a main vertical LinearLayout and set its width and height to match_parent.

  2. Add 9 horizontal LinearLayouts while their width is set to match_parent and their height set to 0dp with layout_weigth equal to 1.

  3. 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

Related Questions