Android--layout:tablelayout

Source: Internet
Author: User



A table layout means that the container is a table where the control is positioned at some point in the table.

which TableRow is to cooperate with Tablelayout used in order to make Tablelayout generate multiple columns, otherwise Tablelayout There can be only one column of elements in it, but there may be multiple rows.

Tablelayoutthe immediate parent class isLinearLayout,so it hasLinearLayoutthe properties,Tablelayouteach row in theTableRowindicates that each column isTableRowThe number specified in the. TableRowthe immediate parent class isLinearLayout,But the way it is placed can only be placed horizontally.


For example:


<?xml version= "1.0" encoding= "Utf-8"? ><tablelayout xmlns:android= "http://schemas.android.com/apk/res/ Android "Android:layout_width=" Fill_parent "android:layout_height=" Fill_parent "> <tablerow android:          Id= "@+id/tablerow1" android:layout_width= "fill_parent" android:layout_height= "Wrap_content" > <textview android:id= "@+id/textview1" android:layout_width= "Wrap_content" Androi D:textappearance= "? Android:attr/textappearancemedium" android:gravity= "center_vertical" Android:pa     ddingleft= "10dip" android:layout_height= "47dip" android:text= "Login"/> </TableRow> <tablerow android:id= "@+id/tablerow2" android:layout_width= "Fill_parent" android:layout_height            = "Wrap_content" > <tablelayout android:layout_weight= "1" android:minheight= "165dip" Android:layout_margin= "10dip"Android:layout_width=" wrap_content "android:layout_height=" wrap_content "> <table Row android:id= "@+id/tablerow5" android:layout_width= "Fill_parent" Android:la                    yout_height= "Wrap_content" > <edittext android:inputtype= "Number" android:layout_marginleft= "5dip" android:layout_marginright= "5dip" android:layout                    _margintop= "10dip" android:id= "@+id/row1" android:layout_weight= "1"                    Android:singleline= "true" android:hint= "user name" android:paddingleft= "10dip"            android:layout_height= "50dip" android:layout_width= "Fill_parent"/> </TableRow> <tablerow android:id= "@+id/tablerow6" android:layou   T_width= "Fill_parent"             android:layout_height= "Wrap_content" > <edittext and                    Roid:inputtype= "Textpassword" android:layout_height= "50dip" android:hint= "password" android:layout_marginleft= "5dip" android:layout_marginright= "5dip" Android                    Oid:id= "@+id/password" android:password= "true" android:layout_weight= "1" Android:singleline= "true" android:paddingleft= "10dip" android:layout_width= " Fill_parent "/> </TableRow> <tablerow android:id=" @+id                /tablerow7 "android:layout_width=" wrap_content "android:layout_marginleft=" 10dip " Android:minwidth= "100dip" android:layout_marginright= "10dip" android:layout_margintop= " 5dip "android:layout_height= "Wrap_content" > <textview and                     roid:text= "Registration >>" android:textcolor= "#009900" android:textsize= "18SP" Android:gravity= "center_vertical" android:layout_weight= "ten" Androi                     D:layout_width= "Wrap_content" android:textappearance= "? Android:attr/textappearancemedium"                                 Android:id= "@+id/textview2" android:layout_height= "Match_parent" /> <button android:layout_weight= "1" an                     Droid:minwidth= "80dip" android:layout_height= "40dip" android:text= "click to login" Android:textcolor= "#fff" android:textsize= "18sp" android:id= "@+id/login "AnDroid:layout_width= "Wrap_content"/> </TableRow> <t Ablerow android:id= "@+id/tablerow8" android:layout_width= "Wrap_content" Andro id:layout_height= "Wrap_content" > </TableRow> </TableLayout> &LT;/TABLEROW&G    T <tablerow android:id= "@+id/tablerow3" android:layout_width= "Wrap_content" android:layout_height= "W Rap_content "> </TableRow></TableLayout>



XML Structure:





Effect after layout is complete:





Compared with the inline layout and relative layout, the Tablelayout layout is more like the bootstrap of the block layout, the layout is flexible and convenient. Suitable for complex layouts.








Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android--layout:tablelayout

Related Article

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.