Common Android Layouts

Source: Internet
Author: User

After the lesson, I found that I am interested in the layout of Android, because the UI is the most intuitive to us, everyone wants to pursue a beautiful program. After Class I compare the book and then search the information on the internet roughly summed up a bit.

There are a few of the layouts we use in Android: LinearLayout (Linear layout), Relativelayout (relative layout), tablelayout (table layout), Absolutelayout (absolute layout), Framelayout (frame layout). But I found that the general framelayout do containers, improper layout to see, because there is no way to complete a single layout. Absolute layout should be a good choice from the number of codes, but for us beginners, the absolute layout is not enough in the present age, because the screen size is so diverse. Regardless of the layout, the width and height of the two properties must be clear, the new UI is always found that some controls are not displayed on the interface, and sometimes in the entire screen. Linear layouts and relative layouts are now widely used in a linear layout that arranges the child elements (which can be controls or layouts) sequentially in a horizontal or vertical order, with each element positioned after the previous element, that is, the control is written sequentially in XML, but not flexible, You cannot specify an arbitrary location. Relative layout is relatively flexible, but it is necessary to learn some properties before learning it.

I specifically studied the relative layout, summed up the various properties

The location of the subclass control relative to the parent class container:

Android:layout_alignparentleft= "true" sub-class control relative to the current parent class container on the left

Android:layout_alignparenttop= "true" sub-class control relative to the current parent class container on top

Android:layout_marginleft= "41DP" subclass control distance from the left side of the parent class container

Android:layout_margintop= "33DP" subclass control distance from top of parent class container

Android:layout_centerinparent= "true" sub-class controls are horizontally and vertically centered relative to the parent class container

Android:layout_centerhorizontal= "true" sub-class controls are centered horizontally relative to the parent class container

Android:layout_centervertical= "true" sub-class controls are centered vertically relative to the parent class container

Left: Android:layout_toleftof

Right: Android:layout_torightof

Top: Android:layout_above

Below: Android:layout_below

Align Upper boundary: android:layout_aligntop

Align bottom boundary: android:layout_alignbottom

Align left boundary: Android:layout_alignleft

Align right boundary: Android:layout_alignright

Left-justified: Android:layout_alighparentleft

Right-aligned: Android:layout_alighparentright

Top alignment: Android:layout_alighparenttop

Bottom alignment: Android:layout_alighparentbottom

Horizontal Center: Android:layout_centerhorizontal

Center vertically: android:layout_centervertical

Central location: android:layout_centerinparent

In the back of the small farmer's practice I also carried out the use, feeling the effect is good, the next preparation for the other layout to learn, a heavy burden ah!

Common Android Layouts

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.