Layouts in Android

Source: Internet
Author: User

LinearLayout Linetype Layout

Android:orientation (direction) = "vertical" (vertical) or "horizontal" (horizontal)

Android:gravity (Gravity) = "Center"

center_vertical Vertical (Y axis) Center

Center_horizontal horizontal (x axis) Center

Center All Center

Right sub-class control is at the left of the current layout

Left sub-class control is on the ieft of the current layout

Bottom Below


If you set the match_parent after setting the weight in the Linetype layout, it will be scaled back


Layout_gravity adjust the position of the layout relative to the parent layout (used only for linearlayout)

Gravity is where you adjust the layout of the sub-layout


Relativelayout Relative layout

Child layout has gravity property, no layout_gravity property

Android:layout_alignparentleft= "true" in the parent class container on the left

android:layout_marginleft= "36DP" distance from the left side of the parent class

Android:layout_centerinparent= "True" is centered in the parent class

Android:layout_centerhorizontal= "True" is centered horizontally in the parent class

android:layout_below= "@id/view" at the bottom of the view

Android:layout_above= "@id/view" on top

android:layout_toleftof= "@id/view" on the Left

Android:layout_alignbaseline= "@id/view" itself aligns with the view content

android:layout_alignbottom= "@id/view" aligns with the bottom of the view


Framelayout Frame Layout

In this layout, all child elements cannot be placed in the specified position, they are all placed in the upper-left corner of the area, and subsequent child elements directly overwrite the preceding child elements.

There are no gravity properties, but subclasses have layout_gravity properties.


Set the foreground map, in front of all child views

Android:foreground

Set background

Android:background

Keep the screen awake

Android:keepscreenon

Set the location of the foreground map

Android:foregroundgravity


Absolutelayout Absolute Layout

Also known as the coordinate layout, you can directly specify the absolute position of the child element (XY)

The device screen size is different, resulting in poor adaptability.

Set the location in the upper-left corner as the starting point:

android:layout_x= "35DP" Control sub-class X position

android:layout_x= "35DP" y position


Tablelayout Table Layout

Manage the subspace in the form of rows, each of which behaves as a TableRow object, or a view

Global properties:

"Android:collapsecolumns="

Hides the index column starting at 0. Columns are separated by commas: 1,2,5


"Android:shrinkclumns="

Shrinks the index column starting at 0. When a Lietaikuan (too much content) is not squeezed out of the screen, the columns must be separated by commas: 1,2,5 can be used instead of shrinking all the columns. A column can represent both contraction and stretching.


"Android:stretchclumns="

Stretches the index column starting at 0 to fill the remaining empty space. Columns are separated by commas, and you can use * instead of stretching all


Local properties (attributes used by the interior space):

android:layout_column= "1" The space is shown in the second column

Android:layout_span= "2" This control occupies 2 columns

Layouts in Android

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.