Android Learning Notes (7) LinearLayout and Android:layout_weight Learning

Source: Internet
Author: User

Tenth lesson for Joshui teacher

One, LinearLayout
Linear layout, layout file set multiple LinearLayout to achieve the overall linear layout style.
Android:gravity= "Right" alignment, gravity is the meaning of the center of gravity
Common parameters: Center (center), Bottom (bottom), Top (top), right (starboard), left

Two, Android:layout_weight
Assigns a discretionary value to a control, without assigning a default of 0
A control with a weight of 0 gives him the layout in its original way; a control that has a weight assigned to it, which is laid out in the area other than the control with a weight of 0,
For example: There are 2 controls in the layout, one android:layout_weight= "2" and the other android:layout_weight= "1" The entire screen two-thirds is occupied by the first control, and the remaining One-third is occupied by the second control.

Example: To implement the layout:


<relativelayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools "android:layout_width=" match_parent "android:layout_height=" Match_parent "Android:paddi ngbottom= "@dimen/activity_vertical_margin" android:paddingleft= "@dimen/activity_horizontal_margin" Android: paddingright= "@dimen/activity_horizontal_margin" android:paddingtop= "@dimen/activity_vertical_margin" tools: Context= ". Mainactivity "><linearlayout android:theme=" @android: Style/theme.notitlebar.fullscreen "android:orientation = "vertical" android:layout_width= "match_parent" android:layout_height= "Match_parent" > <!--Horizontal Layout---& Lt LinearLayout android:orientation= "vertical" android:layout_width= "match_parent" android:layout_height          = "Match_parent" android:layout_weight= "1" > <edittext android:layout_width= "match_parent" Android:layout_height= "Match_parent" andRoid:background= "#ff0000" android:layout_weight= "1" > </EditText> <edittext Android:layout_width= "Match_parent" android:layout_height= "Match_parent" android:layout_weight= "1          "android:background=" #00ff00 "> </EditText> <edittext           Android:layout_width= "Match_parent" android:layout_height= "Match_parent" android:layout_weight= "1"            android:background= "#0000ff" > </EditText> </LinearLayout> <!--vertical Layout--<linearlayout android:orientation= "Horizontal" android:layout_width= "mat Ch_parent "android:layout_height=" Match_parent "android:layout_weight=" 1 "android:layout_gravity=" rig          HT "> <edittext android:layout_width=" match_parent "android:layout_height=" Match_parent " Android:layout_weight= "1" android:background= "#2F2F4F" > </EditText> <edittext and Roid:layout_width= "Match_parent" android:layout_height= "Match_parent" android:layout_weight= "1" a ndroid:background= "#B87333" > </EditText> </LinearLayout> </linearlayout ></RelativeLayout>

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

Android Learning Notes (7) LinearLayout and Android:layout_weight Learning

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.