Position elements on GridLayout from top to bottom then left to right

783 views Asked by At

I need to create a GridLayout with buttons positioned like this:

sample

The problem is that when I add the buttons for each time of day, they are added from left to right, then top to bottom (I mean, it first fills row #1, then go to #2, and so on). This way my buttons are added like this:

08:00  09:00  10:00
11:00  12:00  13:00
...

UPDATE

I want to know if there's any property or such thing so I don't have reinvent the wheel writing a bunch of boilerplate code.

2

There are 2 answers

0
Terminator_NL On

You can simply add buttons in another order. The picture you posted already helps you.

Instead of:

08:00  09:00  10:00
11:00  12:00  13:00

Do:

08:00 12:00 16:00
09:00 13:00 17:00

Hope it helps.

0
beeb On

I think you need to call setOrientation() on your gridlayout and set it to vertical.

check this link:

https://developer.android.com/reference/android/widget/GridLayout.html#setOrientation(int)