Tablelayout of Android layout manager

Source: Internet
Author: User

2. tablelayout

The tablelayout class manages controls in the form of rows and columns. Each behavior is a tablerow object and can also be a view object. When it is a view object, this object will change all columns across rows.

You can set columns as the following attributes.

    • Shrinkable: the column width can be reduced to make the table fit the size of its parent container.
    • Stretchable: the column width can be stretched ,......
    • Collapsed: This column is hidden.
Attribute name Method Description
Android: collapsecolumns Setcollapsed (INT, Boolean) Column starting from 0
Android: shrinkcolums Setshrinkcolumns (Boolean)  
Android: stretchable Setstretchable (Boolean)  

Table_layout.xml

<? XML version = "1.0" encoding = "UTF-8"?>
<Linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android"
Android: layout_width = "fill_parent" Android: layout_height = "fill_parent"
Android: Orientation = "vertical">
<Tablelayout Android: Id = "@ + ID/tablelayout01"
Android: layout_width = "fill_parent" Android: layout_height = "wrap_content"
Android: Background = "@ drawable/White" xmlns: Android = "http://schemas.android.com/apk/res/android">
<Textview Android: Id = "@ + ID/tv01" Android: text = "I Am a separate line .... "
Android: layout_width = "fill_parent" Android: layout_height = "wrap_content"
Android: Background = "@ drawable/darkgray" Android: layout_margin = "4px"/>
</Tablelayout>
<Tablelayout Android: Id = "@ + ID/tablelayout02"
Android: layout_width = "fill_parent" Android: layout_height = "wrap_content"
Android: stretchcolumns = "0"
Xmlns: Android = "http://schemas.android.com/apk/res/android">
<Tablerow Android: Id = "@ + ID/tablerow01" Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content">
<Textview Android: Id = "@ + ID/tv02" Android: text = "I'm a row being stretched"
Android: layout_width = "wrap_content" Android: layout_height = "wrap_content"
Android: Background = "@ drawable/White" Android: layout_margin = "4px"/>
<Textview Android: Id = "@ + ID/tv03" Android: text = "less content"
Android: layout_width = "wrap_content" Android: layout_height = "wrap_content"
Android: Background = "@ drawable/White" Android: layout_margin = "4px"/>
</Tablerow>
</Tablelayout>
<Tablelayout Android: Id = "@ + ID/tablelayout03"
Android: layout_width = "fill_parent" Android: layout_height = "wrap_content"
Android: shrinkcolumns = "0" Xmlns: Android = "http://schemas.android.com/apk/res/android">
<Tablerow Android: Id = "@ + ID/tablerow02" Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content">
<Textview Android: Id = "@ + ID/tv04" Android: text = "I am the compressed row of the compressed row"
Android: Background = "@ drawable/White" Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content" Android: layout_margin = "4px"/>
<Textview Android: Id = "@ + ID/tv05" Android: text = "I have a lot of content, a lot of content"
Android: Background = "@ drawable/White" Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content" Android: layout_margin = "4px"/>
</Tablerow>

</Tablelayout>
</Linearlayout>

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.