Android Five layout Introduction & property Settings Daquan

Source: Internet
Author: User

Objective

In the development of Android, it is often necessary to use a variety of layouts for UI drawing, today we will talk about the most commonly used in Android development of the five major layout and related properties of the settings.

Directory
Android Five layout Introduction & property settings. jpg One, Layout introduction

In Android, there are five ways to layout, namely:

    • Framelayout (Frame layout)
    • LinearLayout (Linear layout)
    • Absolutelayout (Absolute layout)
    • Relativelayout (relative layout)
    • Tablelayout (Table layout)

1. Framelayout Frame Layout

    • Layout features: All the elements placed in it are placed in the leftmost area and cannot be assigned an exact position, and the next child element overlaps the previous child element
    • Application scenario: Suitable for viewing a single picture.

2. LinearLayout Linear layout

    • Layout features: A model that provides a horizontal or vertical arrangement of controls, with each sub-component
      are arranged linearly in a vertical or horizontal manner. (Default is vertical)
    • Application scenario: The most common layout method

      There is an important attribute android:layout_weight= "1" in the LinearLayout, which represents the line spacing when vertical layout, the column width when horizontal, the larger the weight value.

3. Absolutelayout Absolute Positioning layout

    • Layout features: Positioning the component in the way of the axis, the upper left corner is (0,0) point, to the right x axis increment, down the y axis increment, the component positioning property is android:layout_x and android:layout_y to determine the coordinates.
    • Application scenario: Accurate positioning of spatial locations

      The layout is outdated due to the large differences in screen size and resolution of the Android phone and the inability to use absolutelayout to accommodate the adaptation problem

4. Relativelayout Relative layout

    • Layout features: For a component as a reference, to locate the location of the next component layout method.
    • Scenario: A corresponding relationship exists between controls (suitable artifact, recommended)

5. tablelayout Table Layout

    • Layout features: Like table in HTML. Use TableRow to layout, where TableRow represents a row, and each view component of TableRow represents a cell.
    • Scenario: A corresponding relationship exists between controls.

These five layout elements can be nested within each other to make an aesthetically pleasing interface.

Second, Layout property configuration

attribute configuration of XML in Android layout

1. Basic properties of item in five layout:
    • Layout_width & Layout_height
    • layout_margin+ Azimuth & padding+ Azimuth
    • Layout_gravity & Gravity

Android five layouts have several of these basic properties

1. Layout_width & Layout_height

    • Function: Sets the width and height of components in layout
    • Value:
      A. Fixed pixel values
      android:layout_width="66px"
      B. "Wrap_content"
      The width and height of the corresponding view will be set to the minimum size required to fit the contents of the view
      android:layout_width="wrap_content"
      C. "Match_parent" (called "Fill_parent" before Android API 8)
      The width and height of the view extends to the full parent layout
      android:layout_width="match_parent"

2. layout_margin+ Azimuth/padding+ Azimuth

    • Function: Sets the boundary between the view and layout to be placed in layout or the other view can be a distance apart


Carson_ho
Links: http://www.jianshu.com/p/4fac6304d872
Source: Pinterest
Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.

Android Five layout Introduction & property Settings Daquan

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.