Android TableLayout | TableLayout

Downlod TableLayout Sample

Table layout in android is very similer to standard html table. Html <TR> is equivalent to TableRow of android TableLayout. In android TableLayout, 1 View/ViewGroup represent a cell.

In TableLayout, all children are arranged into rows and columns. TableLayout containers do not display border lines for their rows, columns, or cells.

Android TableLayout does't support row span, but similer functionality can be achieved using nested TableLayout.

Xml attributes of android table layout

Xml attribute Description
android:collapseColumns android:collapseColumns specify comma seprated columns that can collapse. Index can be any value between 0 to n-1 where n is total no. of columns.
android:stretchColumns android:stretchColumns specify comma seprated columns that can stretch. Index can be any value between 0 to n-1 where n is total no. of columns.

A column can be collapseable as well as stretchable

android:layout_span android:layout_span specify no. of columns that should span
android:layout_column android:layout_column specify the column index, where you want to display a View/ViewGroup

Layout file of above 2 example of TableLayout are given below:

Login screen using Android table layout

Now let's design a login screen using TableLayout. Create a Android Studio project with some name say LoginDemo under a package xyz.apnatutorial.tablelayout with a empty screen.

Here is the content of modified files.


Share & Like

Tutorial topics

About is for Java, J2ee, Html5 and android developers. All tutorials are well explained and are easy to understand. We have tested every tutorials on our developement environment before posting it in public domain.