Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Align Buttons in GridLayout

My layout code and its graphical representation is:

enter image description here

This is just an example, I have about 30 Buttons in my application inside a GridLayout. I want my Buttons to fill their entire cell in the grid and the grid's columns should be in even width/height.

I cant seem to get it done, any help would be welcome.

like image 216
Aviran Avatar asked Sep 26 '12 12:09

Aviran


1 Answers

I haven't use GridLayout to much to recommend something about using it, what I can recommend you is to use a TableLayout. I say this because your layout fits in the TableLayout's scope pretty well and after a quick browsing of GridLayout's documentation this seems like a problem:

GridLayout does not provide support for the principle of weight, as defined in weight. In general, it is not therefore possible to configure a GridLayout to distribute excess space between multiple components.

Also GridLayout was introduced in ICS.

You can see an example for your layout using TableLayout here:

https://gist.github.com/3788301

If you don't want the table to fill the entire height then remove the weigthSum property from the TableLayout and layout_weight="1" from the TableRows.

like image 187
user Avatar answered Sep 19 '22 21:09

user