Android layout and android layout skills

Source: Internet
Author: User

Android layout and android layout skills

1. LinearLayout

LinearLayout is one of the most common layout s in Android. It lists its child elements in one direction.

The direction can be either horizontal or vertical. In this direction, you can set Android: orientation = "vertical" or Android: orientation = "horizontal.

All elements are arranged one by one. If they are vertically arranged, the LinearLayout elements are arranged one by one vertically from the top down. If they are horizontally arranged, the elements in LinearLayout are arranged one by one from left to right.

2. FrameLayout

A FrameLayout object is like a blank area on the screen with a predefined number. Then, some elements can be filled in, such as an image.

Note that all elements are placed in the top left of the FrameLayout area. In addition, it is impossible to specify an exact location for these elements.

If a FrameLayout contains multiple child elements, the display of the child elements will overlap with the previous one.

3. RelativeLayout

This is a relative layout class. That is to say, RelativeLayout is a container. The elements in it, such as the Button, are calculated based on relative positions. For example, there are two buttons in a RelativeLayout. we can define the second Button on the top or right of the first Button. But where is the second Button? It depends on the position of the first Button. It should be noted that, in terms of performance, the computation at the precise position of the relative layout is only executed once. Therefore, if A visualization component B depends on, A must appear before B.

========================================================== ========================================

Android: id defines the component id

Android: layout_width defines the width of the component (wrap_content only wraps the content and fills the parent container with fill_parent)

Android: layout_height defines the height of the component.

Android: background = "@ drawable/blue" defines the background of the component.

Android: padding = "10dip", Android: margin = "10dip", dip is dependent on the pixel of the device. Padding indicates padding, while margin indicates padding.

Android: layout_below = "@ id/lable": place the current component under the id lable component

Android: layout_alignParentRight = "true", which is aligned with the right side of the parent container.

Android: layout_marginLeft = "10dip"

Android: layout_toLeftOf = "@ id/cancel", set this component to the left of the component whose id is cancel

Android: layout_alignTop = "@ id/cancel", set the height of this component to equal to that of the component whose id is cancel

========================================================== ========================================

 

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.