Tablelayout of the Android UI layout

Source: Internet
Author: User

The literal understanding of tablelayout is a tabular layout. Such a layout arranges the included elements in the form of rows and columns. The number of columns in the table is the maximum number of columns per row. Of course, the cells inside the table can be empty.

Example: Layoutdemo
Execution effect:


Code Listing:
Layout file: Table_layout.xml
<?xml version= "1.0" encoding= "Utf-8"? ><tablelayout xmlns:android= "http://schemas.android.com/apk/res/ Android "Android:layout_width=" Match_parent "android:layout_height=" Match_parent "android:stretchcolumns=" 1 "&    Gt <TableRow> <textview android:gravity= "right" android:textstyle= "bold" and roid:padding= "3dip" android:text= "User name:"/> <edittext android:id= "@+id/username "Android:padding=" 3dip "android:scrollhorizontally=" true "/> </TableRow> < tablerow> <textview android:gravity= "right" android:textstyle= "bold" Android            :p adding= "3dip" android:text= "User password:"/> <edittext android:id= "@+id/password" android:padding= "3dip" android:password= "true"/> </TableRow> <tablerow Andro       Id:gravity= "Right" > <button android:id= "@+id/cancel" android:text= "Cancel"/> <button an Droid:id= "@+id/login" android:text= "Login"/> </TableRow></TableLayout>
In the above layout code, a co-owned 3 rows. That is, 3 TableRow, each with two cells inside each tablerow.


The tablelayout tag defines a table layout (tablelayout).
The TableRow tag defines a row inside the table layout.

Each line is free to add some components. For example, we mainly add the button component and the edit box component on top.

Java source file: Tablelayoutactivity.java

Package Com.rainsong.layoutdemo;import Android.app.activity;import Android.os.bundle;public class  Tablelayoutactivity extends activity{    /** called when the Activity is first created. */    @Override public    Void OnCreate (Bundle savedinstancestate)    {        super.oncreate (savedinstancestate);        Setcontentview (r.layout.table_layout);    }}



Tablelayout of the Android UI layout

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.