Android ApiDemos example resolution (156): Views-& gt; Layouts-& gt; Tabl

Source: Internet
Author: User

Previous: http://www.bkjia.com/kf/201209/153078.html

TableLayout arranges its child views in the form of tables (rows and columns. A TableLayout can contain multiple TableRow objects. Each TableRow defines a row in the table (you can also use other types of child views). TableLayout does not display rows, columns, or cell boundary lines. Each row can contain 0 or more cells, and each cell can display a subview. The number of columns in the final table is determined by the row with the most cells. A table can contain empty cells, and cells can occupy multiple columns (similar to HTML ).

The column width depends on the cell in the column. However, TableLayout can specify the scaling attribute for some columns. If shrinkable is specified, this class can be reduced to adapt to the parent container. If stretchable is specified, the column can be stretched and filled with cells. The table width is determined by its parent container. The cell can specify both shrinkable and stretchable. In this case, the cell is always filled with View. You can call setColumnCollapsed () to hide a column ().

The layout_width attribute cannot be specified for the subview of TableLayout. Its value is always MATCH_PARENT, while layout_height can be specified. The default value is WRAP_CONTENT. If the subview type of TableLayout is TableRow, The layout_height is.

Cells must be added to each row in sequence (XML or code). The column sequence number starts from 0. If no class sequence number is specified for the cell, it is automatically added to the next column, if a column is skipped, The skipped class is considered as a null cell.

If TableRow is not used as a subclass of TableLayout, the View in this row is considered to occupy all columns.

This example shows the basic usage of TableLayout. TableRow is used to define three rows. Each row has three textviews, and the column width of each column is determined by the widest cell of the column:


[Html]
<TableLayout xmlns: android = "http://schemas.android.com/apk/res/android"
Android: layout_width = "match_parent"
Android: layout_height = "match_parent">

<TableRow>
<TextView
Android: text = "@ string/table_layout_1_star"
Android: padding = "3dip"/>
<TextView
Android: text = "@ string/table_layout_1_open"
Android: padding = "3dip"/>
<TextView
Android: text = "@ string/table_layout_1_open_shortcut"
Android: padding = "3dip"/>
</TableRow>

<TableRow>
<TextView
Android: text = "@ string/table_layout_1_triple_star"
Android: padding = "3dip"/>
<TextView
Android: text = "@ string/table_layout_1_save"
Android: padding = "3dip"/>
<TextView
Android: text = "@ string/table_layout_inclusave_shortcut"
Android: padding = "3dip"/>
</TableRow>

<TableRow>
<TextView
Android: text = "@ string/table_layout_1_star"
Android: padding = "3dip"/>
<TextView
Android: text = "@ string/table_layout_1_quit"
Android: padding = "3dip"/>
<TextView
Android: text = "@ string/table_layout_1_quit_shortcut"
Android: padding = "3dip"/>
</TableRow>
</TableLayout>

<TableLayout xmlns: android = "http://schemas.android.com/apk/res/android"
Android: layout_width = "match_parent"
Android: layout_height = "match_parent">
 
<TableRow>
<TextView
Android: text = "@ string/table_layout_1_star"
Android: padding = "3dip"/>
<TextView
Android: text = "@ string/table_layout_1_open"
Android: padding = "3dip"/>
<TextView
Android: text = "@ string/table_layout_1_open_shortcut"
Android: padding = "3dip"/>
</TableRow>
 
<TableRow>
<TextView
Android: text = "@ string/table_layout_1_triple_star"
Android: padding = "3dip"/>
<TextView
Android: text = "@ string/table_layout_1_save"
Android: padding = "3dip"/>
<TextView
Android: text = "@ string/table_layout_inclusave_shortcut"
Android: padding = "3dip"/>
</TableRow>
 
<TableRow>
<TextView
Android: text = "@ string/table_layout_1_star"
Android: padding = "3dip"/>
<TextView
Android: text = "@ string/table_layout_1_quit"
Android: padding = "3dip"/>
<TextView
Android: text = "@ string/table_layout_1_quit_shortcut"
Android: padding = "3dip"/>
</TableRow>
</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.