Course 5 of Android-Preliminary Layout of Android 2-tablelayout Layout

Source: Internet
Author: User

The layout of tablelayout is roughly similar to that of linearlayout, but the differences between the two can be imagined. Those with development experience are certainly not familiar with table, here, tablelayout is actually a similar layout. The display mode on the mobile phone is similar to that on the website. Next I will first display the graph andCodeAnd then explain the important code.

The preceding figure shows a table with two rows and one column.

The following code is used:

Main. xml

<? XML version = "1.0" encoding = "UTF-8"?> <Br/> <tablelayout xmlns: Android = "" <br/> Android: layout_width = "fill_parent" <br/> Android: layout_height = "fill_parent" <br/> Android: stretchcolumns = "1" <br/> <tablerow> <br/> <textview <br/> Android: TEXT = "@ string/row1_column1" <br/> Android: padding = "3dip"/> <br/> <textview <br/> Android: TEXT = "@ string/row1_column2" <br/> Android: gravity = "right" <br/> Android: padding = "3dip"/> <br/> </tablerow> </P> <p> <tablerow> <br/> <textview <br/> Android: TEXT = "@ string/row2_column1" <br/> Android: padding = "3dip"/> <br/> <textview <br/> Android: TEXT = "@ string/row2_column2" <br/> Android: gravity = "right" <br/> Android: padding = "3dip"/> <br/> </tablerow> <br/> </tablelayout>

In the above Code, it is worth noting that the tablerow label is used when a row is inserted in tablelayout, and Android: the stretchcolumns function means that if the content of a row cannot be filled with all layout, use the row number to pull up, and the starting value of stretching in Java starts from 0, so the code above is the second line. If you cannot see clearly, you can add the color of each line for identification. The method of adding a color is to use the Android: Background method in each line,

Padding indicates how far the margin is.


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: 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.