Android Learning Note No.4

Source: Internet
Author: User

Yesterday notebook motherboard bad, a variety of annoying things make a mess, blog did not go on more! But unfortunately the lucky is: Before the notebook motherboard bad, the previous week's notes uploaded up! Saturday to pay the project, small white I, still at 1.1 point to see the Foundation, Alexander Ah!
Five major layouts need to be aware of the points of knowledge:

Linear layout:
LinearLayout is a linear layout control that contains child controls that are arranged in a horizontal or vertical manner!

LinearLayout properties that are commonly used by themselves:
android:orientation= "Vertical"
--this property determines how the sub-class controls are arranged (vertical vertical; horizontal: Horizontal)
android:gravity= "Center"
--this property determines the position of the xy of his sub-class.

Several property values that are commonly used:
1>center_vertical: Vertical (Y axis) centered
2>center_horizontal: Horizontal (x axis) centered
3>center: Horizontal vertical is centered
4>right: The subclass control is on the right side of the current layout
5>left: The subclass control is on the left side of the current layout
6>bottom: The subclass control is below the current layout

Layout_weight
When using, pay attention to the value of layout_height.
When Layout_height is Match_parent
is inversely proportional to the current layout_weight
When Layout_height is Wrap_content
is proportional to the current layout_weight.

Layout_gravity adjust the position of the layout relative to the parent layout
Gravity is the position of the sub-layout that adjusts the layout.

A linearlayout with a orientation for horizontal has a textview, then the TextView property of set layout_gravity does not work for right!

Because the horizontal linearlayout to start with the layout from the left, the Layout_gravity property of TextView does not work!

Layout_alignbottom= "@+id/id1"
Layout_alignbaseline= "@+id/id1"
layout_torightof= "@+id/id1"

The sub-layout inside the relative layout has the Gravity property.
@+id is to add an ID in R.java, @id to refer to an existing ID.
Toleftof is on the left, Torightof is on the right.

Frame layout (framelayout) in this layout, all the child elements cannot be assigned to the position, they are all placed in the upper-left corner of the area, and the subsequent child elements directly above the preceding child elements, the previous child elements partially or completely obscured!

Framelayout has no gravity attribute.
Framelayout How to set up a foreground map: using Android:foreground

Absolutelayout Absolute layout: Also called the coordinate layout, you can directly specify the absolute position of the child element (XY)

Defective and is not recommended for use.

Because the screen size of mobile phones is very different, there is a flaw in the screen fitting.

Absolutelayout sub-class control properties:
Android:layout_x
Android:layout_y

Tablelayout Table Layout

The tabular layout model manages the child controls in the form of rows and columns, each of which behaves as an TableRow object, or it can be an object of another view.

Tablelayout Properties (Global properties)

"Android:collapsecolumns="
Hides the index column for the two or three column. Because the subscript starts at column No. 0. Must be separated by commas: 1,2,5
"Android:shrinkcolumns="
The index column that shrinks the two or three column. Because the subscript starts at column No. 0. When a Lietaikuan (too much content) is not extruded, the columns must be separated by commas, and all columns can be shrunk by means of *.
A column can represent both contraction and stretching.
"Android:stretchcolumns="
Stretches the index column of the two or three column. Because the subscript starts at column No. 0. The index column starting at 0. To fill the rest of the extra empty space, the column must be separated by commas. All columns can be stretched by means of *.

0 is the first column.

Local properties of Tablelayout: properties used for internal space
android:layout_column= "1" The control is displayed in the 2nd column
Android:layout_span= "2" This control occupies 2 columns

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android Learning Note No.4

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.