Linear layouts are represented by the LinearLayout class, and the linear layout of Android is a bit similar to swing's box (they all arrange the components inside the container one after the other), LinearLayout, using Android:o Rientation property controls whether the layout is horizontal or vertical (vertical level, horizontal vertical)
|
XML Properties |
Related methods |
Description |
|
android:baselinealigned |
Setbaselinealigned (Boolean) |
This property is set to False, which prevents the layout manager from having a baseline of its child elements |
|
Android:divider |
Setdividerdrawable (drawable) |
Vertical layout two split bar between buttons |
|
Android:gravity |
setgravity (int) |
Set the alignment of components within the Layout manager, attribute support: top,left,right,center_vertical,fill_vertical, etc. |
|
Android:measurewithlargestchild |
Setmeasurewithlargestchildenabled (Boolean) |
When this property is set to true, all child elements with weights will have the smallest size of the maximum child element |
|
Android:orientation |
setorientation (int) |
Set the alignment of components within the layout manager, Horizontal: horizontal arrangement, vertical: vertical arrangement |
LinearLayout XML attributes common to child elements
|
XML Properties |
Related methods |
Description |
|
Android:layout_gravity |
|
Specifies how the child element is aligned in the LinearLayout |
|
Android:layout_weight |
|
Specifies the weight that the child element occupies in the LinearLayout |
Properties Specific Effects:
- android:baselinealigned Property
<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android" xmlns:tools= "Http://schemas.android.com/tools" android:layout_width= "fill_parent" android:layout_height= "Fill_ Parent "android:baselinealigned=" false "android:orientation=" horizontal "tools:context=" com.example.layouttest.Ma Inactivity "> <textview android:id=" @+id/t1 "android:layout_width=" Wrap_content "Android:la yout_height= "Wrap_content" android:text= "first text"/> <button android:id= "@+id/btn1" Android Oid:layout_width= "Wrap_content" android:layout_height= "Wrap_content" android:text= "First Bton"/> < TextView android:id= "@+id/t2" android:layout_width= "wrap_content" android:layout_height= "Wrap_conten T "android:text=" a second text "/></LINEARLAYOUT>
- Android:gravity Property
<linearlayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools " android:layout_width=" fill_parent " android:layout_height=" Fill_parent " android:orientation= "vertical" android:gravity= "right" tools:context= " Com.example.layouttest.MainActivity "> <textview android:id=" @+id/t1 " android:layout_width=" Wrap_content " android:layout_height=" wrap_content " android:text=" first text "/> <button Android:id= "@+id/btn1" android:layout_width= "wrap_content" android:layout_height= "Wrap_content" android:text= "First Bton"/> <textview android:id= "@+id/t2 " android:layout_width= "Wrap_ Content " android:layout_height=" wrap_content " android:text=" second text "/></linearlayout>
Android layout manager (Linear layout)