[Android] Chapter 2 (2)-common public attributes of layout controls, Chapter 2 of android

Source: Internet
Author: User

[Android] Chapter 2 (2)-common public attributes of layout controls, Chapter 2 of android

Category: C #, Android, VS2015;

Created on:

I. Introduction

The layout controls in Android applications are container controls used to control the arrangement and placement of child elements. The layout controls provided by Android include:

  • LinearLayout: Linear layout.
  • GridLayout: grid layout.
  • TableLayout: table layout.
  • FrameLayout: Framework layout.
  • Relative Layout: Relative Layout.
  • AbsoluteLayout: absolute layout.

 

2. Common public attributes

Each layout control (layout) in Android is a container element that can be used to combine multiple child elements. Some basic attributes are common. Common basic attributes include:

1. id

Android: id: "@ + id/id1" indicates that this id is newly added and its name is id1.

"@ Id/id1" indicates that this id references the id1 control.

2. padding

Android: padding.

3. fill_parent and match_parent

Android: fill_parent or match_parent: indicates that the width (or height) is the same as that of the parent element.

4. wrap_content

Android: wrap_content: indicates that the width (or height) is automatically adjusted with the content. You can also directly use the px value to set the width or height (related to the pixel density), or use dp to set the width or height (not related to the pixel density ).

5. layout_weight

Android: layout_weight: the importance of filling the remaining space on the screen (also called priority or weight ). The default value is 0 (highest). The higher the value, the lower the priority. The priority takes effect only when the corresponding layout_width/layout_height = "fill_parent" of the parent layer; otherwise, wrap_content will be compressed to occupy only the minimum available space.

6. layout_gravity and gravity

Android: layout_gravity: Alignment of the control in its container control. That is, to which side is sunk (gravity: gravity ).

Android: gravity: Alignment of the text in the control (to which end the text is sunk ).

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