Android Notes (ix) layout in Android-table layout

Source: Internet
Author: User

Tablelayout runs the way we use tables to arrange the controls, the essence of which is still the linear layout. Table layouts manage controls in the form of rows and columns, and Tablelayout does not require an explicit declaration of how many rows are included, but rather by adding tablerow, other components to control the number of rows and columns of the table.

Each time you add a tablerow to a table, the TableRow is a table row, and TableRow is also a container, so it can add additional components continuously, adding a column to the table for each child component.

Example code to implement a simple login interface

Tablelayout.xml

<?XML version= "1.0" encoding= "Utf-8"?><Tablelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"Android:stretchcolumns= "1">    <TableRow>        <TextViewAndroid:layout_height= "Wrap_content"Android:text= "Account:"/>        <EditTextAndroid:id= "@+id/usernameinput"Android:layout_height= "Wrap_content"Android:hint= "Enter the user name to register"/>    </TableRow>    <TableRow>        <TextViewAndroid:layout_height= "Wrap_content"Android:text= "Password:"/>        <EditTextAndroid:id= "@+id/passwordinput"Android:layout_height= "Wrap_content"Android:hint= "Input to Password"/>    </TableRow>    <TableRow>        <ButtonAndroid:id= "@+id/loginbutton"Android:layout_height= "Wrap_content"Android:layout_span= "2"Android:text= "Login"/>    </TableRow></Tablelayout>

The results shown are:

  

Obviously, it's ugly, we want to have a certain amount of space between the left and right sides, and all of the components are in the middle of the screen, and there are some properties that need to be combined to achieve these effects.

android:collapsecolumns= "0"--Hide No. 0 column

android:shrinkcolumns= "0"-Shrinking No. 0 column

android:stretchcolumns= "0"--Stretching the No. 0 column

Android Notes (ix) layout in Android-table 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.