GridLayout vs TableLayout
Asked Answered
S

1

8

I'm unsure as to what the differences between the two of them are and which I should use for my purpouses?

What I'm trying to do is create a custom virtual numpad with text inputs and that can dynamically change its contents to have a date picker.

So I need a layout system which supports many different sized cells inside it.

Which better suits my needs and what's the difference?

Siddra answered 30/4, 2013 at 13:0 Comment(3)
Check this SO posts: #11307718 https://mcmap.net/q/401200/-grid-layout-vs-table-layoutCretin
First link is a comparison between GridView and GridLayout, second post was made before GridLayout had come out in Android, I've already seen both links and neither helped, hence my question.Siddra
Ok check this link technicalmumbojumbo.wordpress.com/2011/12/08/… Hope this will make your doubt clear to some extent.Cretin
A
10

In my experience I had both GridLayout and TableLayout give me the same results. They both seem to stretch the columns to fit the widest child element. Neither will give you gird lines or borders around the cells.

From the official docs on GridLayout:

Row and Column Specs Children occupy one or more contiguous cells, as defined by their rowSpec and columnSpec layout parameters. Each spec defines the set of rows or columns that are to be occupied; and how children should be aligned within the resulting group of cells. Although cells do not normally overlap in a GridLayout, GridLayout does not prevent children being defined to occupy the same cell or group of cells. In this case however, there is no guarantee that children will not themselves overlap after the layout operation completes.

and from the TableLayout:

The table has as many columns as the row with the most cells. A table can leave cells empty. Cells can span columns, as they can in HTML.

So it seems to me that the GridLayout is a bit more versatile and probably what you are looking for.

Angelikaangelina answered 30/4, 2013 at 13:37 Comment(2)
Can a cell in grid layout be left empty?Eyla
@Malwinder, I saw this effect at developer.alexanderklimov.ru/android/layout/gridlayout.php.Busyness

© 2022 - 2024 — McMap. All rights reserved.