Creating tables – TableLayout and GridLayout
When you need to create a table in your UI, Android provides two convenient layout options: the TableLayout
(along with TableRow
) and the GridLayout
(added in API 14). Both layout options can create similar looking tables, but each using a different approach. With the TableLayout
, rows and columns are added dynamically as you build the table. With the GridLayout
, row and column sizes are defined in the layout definition.
Neither layout is better, it's just a matter of using the best layout for your needs. We'll create a 3 x 3 grid using each layout to give a comparison, as you could easily find yourself using both layouts, even within the same application.
Getting ready
To stay focused on the layouts and ...
Get Android Application Development Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.