Use of stretchcolumns and shrinkcolumns in tablelayout

Source: Internet
Author: User

Android: stretchcolumns = "1" Android: shrinkcolumns = "1" are unique to tablelayout and affect the layout of sub-objects.
Table layout organizes the child view layout by row and column. Table layout contains a series of tabrow objects for defining rows (you can also use other sub-objects ). The table layout does not display table lines for its rows, columns, and cells. Each row can contain more than one (including) cell, and each cell can set a view object. Like a row that contains many cells, a table contains many columns. The table cell can be empty.

The column width is determined by the widest cell in all rows of the column. however, the table layout can be marked with two attributes: shrinkcolumns and stretchcolumns. Some columns can be shrunk or stretched. if it is marked as condensed, the column width can be reduced to make the table fit the container size. If it is marked as extensible, the column width can be stretched to occupy extra space. The total width of a table is determined by its parent container. Remember that a column can have both the extensible and extensible attributes. Finally, you can set the collapsecolumns attribute to hide columns.

The Android: layout_width attribute cannot be specified for sub-objects in table layout. The width is always "match_parent ". However, sub-objects can define the Android: layout_height attribute. The default value is wrap_content. If the sub-object is tablerow, its height will always be wrap_content.

Although the typical sub-objects of a table layout are table rows, you can use any subclass of the View class as the direct sub-objects of the table view. the view is displayed as a cell with only one row and all columns. Android: stretchcolumns = "1" sets the second column of the row used as the extension column. If there are three rows, the remaining space is filled by the second row.

Similarly, Android: stretchcolumns = "0" sets the second column of the row to the Extended Column.

Android: shrinkcolumns = "1" sets the second column of the row to shrink the column

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.