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:
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"?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:background="#000044">
<TableRow>
<TextView id="@+id/textName"
android:text="Name:"
android:textColor="#ffffff" />
<EditText id="@+id/editName"
android:width="240px" />
</TableRow>
<TableRow>
<TextView id="@+id/textPasswd"
android:text="Password:"
android:textColor="#ffffff" />
<EditText id="@+id/editPasswd"
android:password="true" />
</TableRow>
<TableRow>
<Button id="@+id/buttonSignIn"
android:text="Sign In" />
</TableRow>
</TableLayout>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:background="#000044">
<TableRow>
<TextView id="@+id/textName"
android:text="Name:"
android:textColor="#ffffff" />
<EditText id="@+id/editName"
android:width="240px" />
</TableRow>
<TableRow>
<TextView id="@+id/textPasswd"
android:text="Password:"
android:textColor="#ffffff" />
<EditText id="@+id/editPasswd"
android:password="true" />
</TableRow>
<TableRow>
<Button id="@+id/buttonSignIn"
android:text="Sign In" />
</TableRow>
</TableLayout>
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
Source: Google Android
9 comments:
Try to enter long password and layout become screwed
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.
Can we poistion the whole table ...
like
android:layout_x="125px"
android:layout_y="50px"
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
http://android-solution-sample.blogspot.com
Thanks
Hi..
Great tutorial i have learn a lot of things,
Thanks
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
It is actual accessible and advantageous one.Thanks for sharing.
Thanks for the nice tutorial man... Even this
www.compiletimeerror.com/2013/07/android-tablelayout-example.html might help, have a look...
Hi, Really great effort. Everyone must read this article. Thanks for sharing.
Post a Comment