Five android la s

Source: Internet
Author: User

XML (Extensible Markup Language) is a scalable Markup Language. Xml is cross-platform in the Internet environment and relies on content technology. It is a powerful tool for processing structured document information.

Android layout is an important part of application interface development. In Android, there are five layout Methods: LinearLayout (linear layout) and FrameLayout (Framework layout ).
Bureau), AbsoluteLayout (absolute layout), RelativeLayout (relative layout), TableLayout (table layout ).
1. LinearLayout
Linear layout, which can be understood as a div from the external frame. First, it is listed one by one on the screen. Each LinearLayout can be divided into vertical layout (android: orientation = "vertical") and horizontal layout (android: orientation = "horizontal "). In vertical layout, each row has only one element, and multiple elements are vertical down in sequence. in horizontal layout, there is only one row, and each element is arranged to the right in sequence.
LinearLayout has an important attribute android: layout_weight = "1". In vertical layout, this weight represents the line spacing; in horizontal layout, it represents the column width; the larger the weight value, the larger the value.
The preview in the linear layout is exactly the same as that in the real machine.
TextView occupies a certain amount of space and has a certain width and height without a value assignment. Pay special attention to this.
Ii. FrameLayout
FrameLayout is the simplest layout object. It is customized as a blank standby area on your screen, and then you can fill in a single object-for example, an image you want to publish. All child elements are fixed in the upper left corner of the screen. You cannot specify a position for a child element in FrameLayout. The next child element directly overwrites the previous child element and blocks them in part or whole (unless the last child element is transparent ).
Iii. AbsoluteLayout
The layout of AbsoluteLayout is very simple. The main attribute is that layout_x and layout_y define the absolute position of the component respectively. That is, the x and y values of the coordinate axes (0, 0) in the upper left corner of the screen increase when the coordinate values move downward or to the right. AbsoluteLayout has no page border and allows elements to overlap with each other (although not recommended ). We generally do not recommend AbsoluteLayout unless you have a legitimate reason to use it, because it makes the interface code too rigid, so that it can work well on different devices.
Iv. RelativeLayout
The relative layout can be understood as the layout method for positioning an element as a reference object.
Android: layout _ direction = id indicates that the id corresponds to the control direction (up | down)

Android: layout_align direction = id indicates alignment with the control (upper-lower-left)

Android: layout_to direction Of = id indicates to the left or right Of the control
Eg:
Android: layout_below = "@ id/la1"/>
Place the current control under the control with the id of la1.
Android: layout_alignParentRight = "true"
Align the right end of the current control with the right end of the parent control. The attribute value can only be true or false. The default value is false.
Android: layout_marginLeft = "10dip"
Empty space on the left of the current control.
Android: layout_toLeftOf = "@ id/true"
Place the current control on the left of the control whose id is true.
Android: layout_alignTop = "@ id/OK"
Align the current control with the upper end of the control with the id of OK.

5. TableLayout

The Table layout is similar to the Table in Html. Each TableLayout contains the table row TableRow, which can define each element. Each TableRow defines a row (in fact, you can define other sub-objects, which will be explained below ). The TableLayout container does not display the border lines of row, cloumns, or cell. Each row has 0 or more cells, and each cell has one View object. A table consists of columns and rows in multiple cells. The table allows cells to be empty. Cells cannot span columns, which is different from HTML.
TabRow only applies to rows, regardless of columns (custom columns ).

Each layout has its own method. In addition, these five layout elements can be nested with each other to create a beautiful interface.


From sweet

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.