Android Learning sixth chapter (layout one tablelayout)

Source: Internet
Author: User

Today, let's simply say that Android is not centered on the Tablelayout layout (table layout)

The table layout means to think of our layout as a table, primarily for arranging controls neatly

Let's look at a simple case

  

<Tablelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:tools= "Http://schemas.android.com/tools"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"Tools:context= "Com.example.activitylife.MainActivity"Android:stretchcolumns="*">    <TableRowAndroid:layout_width= "Match_parent"Android:layout_height= "Wrap_content">        <TextViewAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "One"android:gravity= "Center"Android:background= "@android: Color/holo_blue_dark"/>        <TextViewAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "Two"android:gravity= "Center"Android:background= "@android: Color/holo_green_dark"/>        <TextViewAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "three"android:gravity= "Center"Android:background= "@android: Color/holo_blue_dark"/>        <TextViewAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "Four"android:gravity= "Center"Android:background= "@android: Color/holo_green_dark"/>            </TableRow>    </Tablelayout>

    

Here we can see an attribute Android:stretchcolumns

Here we need to know a few properties in Tablelayout

Android:stretchcolumns sets the columns that can be stretched. The column can stretch to the row direction, up to a full row.

Android:shrinkcolumns sets the columns that can be shrunk. When the column control has too much content and is already packed in the row, the contents of the child control are displayed in the columns direction.

Android:collapsecolumns sets the columns to hide.

After that, let's take a look at some simple examples of what you can do with tablelayout:

  

<Tablelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:tools= "Http://schemas.android.com/tools"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"Tools:context= "Com.example.activitylife.MainActivity"Android:stretchcolumns="*">                    <TextViewAndroid:layout_width= "Match_parent"Android:layout_height= "100DP"Android:background= "@android: Color/holo_blue_bright"android:textsize= "30DP"Android:text= "0"android:gravity= "Right|center"/>        <TableRowAndroid:layout_width= "Match_parent"Android:layout_height= "Match_parent"Android:layout_weight= "1">        <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Match_parent"Android:text= "1"/>        <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Match_parent"Android:text= "2"/>        <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Match_parent"Android:text= "3"/>                <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Match_parent"Android:text="+"/>            </TableRow>        <TableRowAndroid:layout_width= "Match_parent"Android:layout_height= "Match_parent"Android:layout_weight= "1">        <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Match_parent"Android:text= "4"/>        <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Match_parent"Android:text= "5"/>        <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Match_parent"Android:text= "6"/>                <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Match_parent"Android:text="-"/>            </TableRow>        <TableRowAndroid:layout_width= "Match_parent"Android:layout_height= "Match_parent"Android:layout_weight= "1">        <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Match_parent"Android:text= "7"/>        <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Match_parent"Android:text= "8"/>        <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Match_parent"Android:text= "9"/>                <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Match_parent"Android:text="*"/>            </TableRow>        <TableRowAndroid:layout_width= "Match_parent"Android:layout_height= "Match_parent"Android:layout_weight= "1">        <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Match_parent"Android:text= "0"/>        <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Match_parent"Android:text="."/>        <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Match_parent"Android:text="/"/>                <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Match_parent"Android:text="="/>            </TableRow>        <TableRowAndroid:layout_width= "Match_parent"Android:layout_height= "Match_parent"Android:layout_weight= "1">        <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Match_parent"Android:text="="Android:layout_span= "4"/>                    </TableRow>            </Tablelayout>

:

  

Android Learning sixth chapter (layout one 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.