Android: Control layout (table layout) tablelayout

Source: Internet
Author: User

Tablelayout Inheritance LinearLayout

How many rows are there in a TableRow object?

Number of columns equal to TableRow of most child controls

Directly in the Tablelayout control, the control will occupy a row

Tablelayout Properties:

Android:shrinkcolumns-------Set the columns that can be shrunk (the content is too much, then shrinks, expands to the second row, the control does not work when the tablelayout is not covered)

Android:stretchcolumns------Set extendable columns (filled with blanks)

Columns can have both Stretchcolumns and Shrinkcolumns properties

Android:collapsecolumns------Setting the columns to hide

Cell Properties:

Android:layout_column-------The cell is displayed in the first few columns

Android:layout_span-------The cell occupies a number of columns, the default is 1

Stretch Shrink instance:

<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical" >    <!--Table 1-Stretching -    <TablelayoutAndroid:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:background= "#ff0000"Android:shrinkcolumns= "0,1,2" >        <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "I occupy one line" />        <TableRow>            <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "000000000000000000000000" >            </Button>            <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "111111111111111111111111" >            </Button>            <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "222222222222222222222222" >            </Button>        </TableRow>        <TableRow>            <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "000000000000000000000000" >            </Button>            <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:layout_span= "2"Android:text= "I occupy 2 columns" >            </Button>        </TableRow>    </Tablelayout>    <!--Table 2-Shrinkage -    <TablelayoutAndroid:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:background= "#FFCD6B"Android:stretchcolumns= "0,1" >        <TableRow>            <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "Fill One" />            <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "Fill Two" />            <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "Normal three" />        </TableRow>    </Tablelayout></LinearLayout>

 

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.