Hello,
I would like to have a layout with 5 times 5 buttons. Each of them should have the same width and height (they should be square). And I want the whole matrix to use the screen width (or height, depending on rotation).
I currently do it "by hand" in the Java code:
for (int y=0; y<5; y++) {
TableRow tr = new TableRow(this);
for (int x=0; x<5; x++) {
Button b = new Button (this);
...
tr.addView(b, 60, 60);
}
layout.addView(tr);
}
This can be improved by obtaining screen width first and then dividing by 5 to get rid of this literal 60. But I'm wondering how I can do this in the res/layout XML file?
How can I specify for the height to be the same as the width? (I can set the width to match_parent.)
Thank you.