Friday, December 7, 2007

TableLayout Example

Today's sample code will implement very similar UI to the one created in the LinearLayout Example. But here we will be using a TableLayout widget instead.

Each TableLayout consists of a number of TableRow objects and each TableRow object contains zero or more cells. Each cell can hold one View object. The table has as many columns as the row with the most cells and cells can of course span columns. Here is a simple example of a "Sign In" form created with the TableLayout container:
<?xml version="1.0" encoding="utf-8"?>
<TextView id="@+id/textName"
android:textColor="#ffffff" />
<EditText id="@+id/editName"
android:width="240px" />
<TextView id="@+id/textPasswd"
android:textColor="#ffffff" />
<EditText id="@+id/editPasswd"
android:password="true" />
<Button id="@+id/buttonSignIn"
android:text="Sign In" />
Notice, that there aren't specified layout_width and layout_height attributes in the XML file. It's because TableRow always enforces those values to be respectively fill_parent and wrap_content.

Source: Google Android


Marvel said...

Try to enter long password and layout become screwed

VOIP Headphones said...

This is great. I just saw a review of Professional Android 2 Application Development and thought I would get into programming again.

This is cool.

Dj said...

Can we poistion the whole table ...

mike said...

From operating systems to multimedia, PC & mobile games to anti-virus, from drivers to registry cleaners and internet tools our website features all the latest soft wares for safe and free downloading enjoy

Programing Solution said...

Nice contents, you can get more android sample example, solution, tutorial and basic examples of the android programs, like gridview, progressdialog, readwrite sdcard, download data, simple buttonclick, etc on


Adobe flash crash said...


Great tutorial i have learn a lot of things,

Android app development said...

This is one of the Important post.Thanks for providing the Information about Android application.This is one of the suitable post.Android app developers

Forum hosting said...

It is actual accessible and advantageous one.Thanks for sharing.

Meghna said...

Thanks for the nice tutorial man... Even this
might help, have a look...

Mobile App Developers said...

Hi, Really great effort. Everyone must read this article. Thanks for sharing.