. NET programmer play to Android development---(8) Table layout tablelayout

Source: Internet
Author: User

table Layout Tablelayout is a relatively common layout control in Android, since it is a table, there must be rows and columns, rows in Tablelayout have TableRow, and columns are determined based on the number of controls per row

If the first row has 3 controls and the 2nd row has 4 controls, the number of columns in the table will go to the maximum number of columns, or 4 columns.

1. Introduction to Properties

The table has several important properties

android:shrinkcolumns= "2" auto-shrinking columns, multiple columns separated by commas, auto-shrink means that if the contents of the column exceed the width of the table column, it automatically displays downward

android:stretchcolumns= "1" Auto scaling column, multiple columns separated by commas, if all the columns in the table are not full table width, the column automatically scaling.

Android:collapsecolumns hides the specified column, with multiple columns separated by commas

Android:layout_column= "1" is used to set the number of columns for the control in the table.

Android:layout_span used to set the number of columns for a control in a table

<?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:shrinkcolumns=" 2 "a ndroid:stretchcolumns= "1" > <tablerow android:id= "@+id/tablerow1" android:layout_width= "Wrap_con            Tent "android:layout_height=" Wrap_content "> <textview android:id=" @+id/textview1 "             Android:layout_width= "Wrap_content" android:layout_height= "Wrap_content" android:text= "Label 1"            android:background= "#FF82AB"/> <textview android:id= "@+id/textview2"               Android:layout_width= "Wrap_content" android:layout_height= "Wrap_content" android:text= "Label 2"            android:background= "#EE6A50"/> <textview android:id= "@+id/textview3" Android:layout_width= "Wrap_content"            android:layout_height= "Wrap_content" android:text= "I am auto scaling column, too much content, auto-scaling down" android:backg round= "#B3EE3A"/> </TableRow> <tablerow android:id= "@+id/tablerow1" Andro Id:layout_width= "Wrap_content" android:layout_height= "wrap_content" > <textview android:id=            "@+id/textview4" android:layout_width= "wrap_content" android:layout_height= "Wrap_content" android:text= "Label 4" android:background= "#FF82AB"/> <textview android:id= "@ +id/textview5 "android:layout_width=" wrap_content "android:layout_height=" Wrap_content "a ndroid:text= "Automatic" android:background= "#EE6A50"/> <textview android:id= "            @+id/textview6 "android:layout_width=" wrap_content "android:layout_height=" Wrap_content "      android:text= "Label 6"         android:background= "#B3EE3A"/> </TableRow></TableLayout> 

2. Examples of commodity listing




. NET programmer play to Android development---(8) Table layout tablelayout

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.