Introduction to Android LinearLayout, absolutelayout usage examples to explain _android

Source: Internet
Author: User

This example introduces the use of LinearLayout and Absolutelayout in Android, hoping to help a novice Android friend. The specific contents are as follows:

Android's UI layout is layout as a container, and it arranges the controls as specified above, which is similar to the Java Swing and Lwuit. Controls and layout have many properties that are the same, can be modified in properties, and the. Net/delphi and other rad similar, where the most commonly used properties have the following:

Id= "@+id/edtinput", ID is a bridge linking UI to code

gravity= "Center", center of Control in Layout

Layout_width= "Fill_parent", automatically populated to screen width, layout_height the same

Layout_width= "Wrap_content", automatically populated as control size, layout_height

LinearLayout, the layout used in the Android primer is LinearLayout, which is simple to understand: controls inside the linearlayout, arranged horizontally or vertically:
orientation= "Horizontal": horizontal arrangement; orientation= "vertical": vertical arrangement
When LinearLayout is horizontal, and the controls inside use layout_width= "Fill_parent", the second set of controls will block the right side of the screen, which is invisible.

Absolutelayout, a layout defined according to absolute coordinates, uses absolute coordinates to locate controls, so you should use absolutelayout sparingly when implementing an adaptive interface. The controls inside the Absolutelayout define their location in layout_x, layout_y:

The x coordinates of the TextView01 in the above figure are 10px,y coordinates 10px, and the page layout code is as follows:

<absolutelayout android:id= "@+id/absolutelayout01" android:layout_height= "Wrap_content" Fill_parent "> 
<textview android:text=" TextView01 "android:id=" @+id/textview01 "android:layout_height=" Wrap_content "android:layout_y=" 10px "android:layout_width=" wrap_content "android:layout_x=" 110px "> 
</ Textview> 
</AbsoluteLayout>
Related Article

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.