Basic knowledge-UI Layout Design

Source: Internet
Author: User

1. In the SRC file, Main. Java must be bound to the layout file. xml.

Setcontentview (R. layout. main_activity.xml); XML is introduced to mainactivity. java. 2. Linear layout: linearlayout is a linear layout control. The child controls are sorted horizontally or vertically. (1) linearlayout attribute orientation (vertical: vertical; Horizontal: horizontal sorting) (2) gravity attribute: determines the position of the subclass control on the XY axis. center_vertical: center the vertical Y axis.
Center_horizontal: horizontal X axis centered
Center: center horizontally and vertically
Right: The subclass control is located on the right of the current layout.
Left: The subclass control is located on the left of the current layout.
Bottom: The subclass control is located below the current layout.
For example: Android: gravity = "bottom/center_horizontal"-"center", while "layout_gravity" refers to the position of the subclass control (this control). Gravity is used to represent the position of all subclass controls!
3. Relative layout relativelayout: The child controls contained in the relative layout control are arranged in the form of relative positions between controls or the positions of child widgets relative to parent class containers. Position of the following attribute stone control relative to the parent class
Align --- relative position margin -- The following is the position between the control and the control: layout_alignxxxx must be specified based on the control (that is, the value = "@ + ID/xxxx ") 4. All child elements (child Controls) in the framelayout frame layout cannot be placed in the specified position. They are all placed in the upper left corner of the area, and the subsequent elements overwrite the previous elements. 5. Absolute layout absolutelayout, also known as coordinate layout, can directly point to the absolute position of the stator control (via XY coordinates ).
Disadvantage: poor adaptability due to inconsistent screen sizes.
Usage: Android: layout_x = "35dp"
Android: layout_y = "35dp"
6. tablelayout manages child controls in the form of tables (columns). Each row is a tablerow object or a view object. Android: collapsecolunms = "1, 2"-"hides the column number (starts from 0), indicating to hide the second and third columns. Android: shrinkcolumns = "" 1, 2-"indicates that the content of the first column can be shrunk and will not go beyond the screen (from 0 ).
Android: shretchcolumns = "1, 2"-"indicates the number of columns occupying the remaining row space. The second and third columns currently occupy the remaining row space.
Android: layout_column = "1"-"indicates the number of columns in which the control is displayed. Currently, it is explicitly displayed in the first column (from 1 ).
Android: layout_span = "2"-"This control occupies several columns. Currently, it occupies two columns (width ).





From Weizhi note (wiz)



Basic knowledge-UI Layout Design

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.