Third, Android learning the layout of the--activity the first introduction

Source: Internet
Author: User

(Transferred from: http://wenku.baidu.com/view/af39b3164431b90d6c85c72f.html)

Third, Android learning the layout of the--activity the first introduction

Today, we summarize some knowledge of the activity related layouts:

The simplest of activity is divided into two types of layouts:

①linearlayout--Linear layout

②tablelayout--Table layout

③relativelayout-relative layout (this layout will be used frequently in the future)

Here's a brief summary of some of the properties commonly used in the first two (linear/tabular) layouts:

①android:id--the appropriate ID for the specified control

②android:text--the text content that is displayed in the specified control, using @strings.** as much as possible

③android:gravity--specifies where content in the control is displayed, such as centering properties

④android:textsize--Specifies the size of the font in the control, in PT (points), and so on

⑤android:background--Specifies the background color of the control, note that the RGB nomenclature is used, such as "#aa0000"

⑥android:layout_width--the width of the specified control

⑦android:layout_height--the height of the specified control

⑧android:padding--Specifies the padding for the control, note that it can be set up or down separately

⑨android:sigleline--true/false, set to True to display the contents of the control in the same profession

⑩android:weight--Specifies the screen scale of each control, if one screen has two controls, one of which is set to 5, the other is set to 2, the first control occupies 5/7 of the entire screen, and the other control is 2/7

Of course, we can use the layout nested way to achieve more complex, more beautiful layout style, for example, LinearLayout can be nested in any number of other layouts, tablelayout is the same, here does not give an example, the online search a bunch of

In fact, familiar with the page writing, JSP, CSS and so on nested not unfamiliar, and web programming has the same wonderful

Here's a brief summary of some of the properties commonly used in the first two (relative) layouts:

Relative layouts depend on the location of other controls, which can be more complex than the first two layout operations.

We have divided the controls used in relative layouts into groups that are easy to remember

First group: Two controls up or down the Alignment property: (Specify the offset control by ID)

①android:layout_below--to place the control under the specified control

②android:layout_above--to place the control on top of the specified control

③android:layout_toleftof-aligns the right edge of the control with the left edge of the specified control

④android:layout_torightof--aligns the left edge of the control with the right edge of the specified control

Second group: Two controls up or down the Alignment property: (Specify the offset control by ID)

⑤android:layout_alignbottom--aligns the bottom edge of the control with the bottom edge of the specified ID

⑥android:layout_alignleft--aligns the left edge of the control with the left edge of the specified ID

⑦android:layout_alignright--aligns the right edge of the control with the right edge of the specified ID

⑧android:layout_aligntop--aligns the top edge of the control with the top edge of the specified ID

Group Three: Properties aligned with parent controls: (True/false two property values)

⑨android:layout_alignparentleft--aligns the left edge of the control with the left edge of its parent control

⑩android:layout_alignparentright--aligns the right edge of the control with the right edge of its parent control

⑾android:layout_alignparentbottom--aligns the bottom edge of the control with the bottom edge of its parent control

⑿android:layout_alignparenttop--aligns the top edge of the control with the top edge of its parent control

Group Fourth: Centering properties

⒀android:layout_centerinparent--specifies that the control is centered horizontally vertically

⒁android:layout_centerhorizontal--specifies that the control is centered horizontally

⒂android:layout_centervertical--specifies that the control is centered vertically

People here should be very confused, the first group and the second group alignment looks the same, the following two examples:

Android:layout_toleftof

Align the left edge of control one with the right edge of the control two

Android:layout_alignleft

The left edge of control one is aligned with the left edge of control two

Look out, these two sets of attributes have an essential difference.

In the future use, you can choose according to the need ~ ~ ~

These are verbal, if we want to understand the role of these properties, we try to do it yourself, here is not to cite examples, just for everyone to make a summary, once again check ~ ~ ~

See you tomorrow ~

Three, Android learning the third day of--activity layout of the initial introduction (Turn)

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.