First, Introduction
Two
1.linear_layout.xml
1<?xml version= "1.0" encoding= "Utf-8"?>2<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"3Android:layout_width= "Match_parent"4android:layout_height= "Match_parent"5android:orientation= "Horizontal"6android:background= "#440000" >7 8<LinearLayout9android:orientation= "Vertical"TenAndroid:layout_width= "Wrap_content" Oneandroid:layout_height= "Wrap_content" Aandroid:background= "#ff0000" > -<TextView -Android:layout_width= "Wrap_content" theandroid:layout_height= "Wrap_content" -Android:textsize= "20SP" -android:text= "One"/> -<TextView +Android:layout_width= "Wrap_content" -android:layout_height= "Wrap_content" +Android:textsize= "30SP" Aandroid:text= "Two"/> at</LinearLayout> - -<LinearLayout -android:orientation= "Vertical" -Android:layout_width= "Wrap_content" -android:layout_height= "Wrap_content" inAndroid:background= "#00ff00" -android:layout_marginleft= "20DP" > to<TextView +Android:layout_width= "Wrap_content" -android:layout_height= "Wrap_content" theAndroid:textsize= "20SP" *android:text= "One"/> $<TextViewPanax NotoginsengAndroid:layout_width= "Wrap_content" -android:layout_height= "Wrap_content" theAndroid:textsize= "30SP" +android:text= "Two"/> A</LinearLayout> the</LinearLayout>
2.layout_weight.xml
1<?xml version= "1.0" encoding= "Utf-8"?>2<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"3Android:layout_width= "Match_parent"4android:layout_height= "Wrap_content"5android:orientation= "Horizontal"6android:background= "#440000" >7 8<TextView9Android:layout_width= "0DP"Tenandroid:layout_height= "Wrap_content" OneAndroid:textsize= "20SP" AAndroid:background= "#00ff00" -android:text= "11111111" -android:layout_weight= "1"/> the<TextView -Android:layout_width= "0DP" -android:layout_height= "Wrap_content" -Android:textsize= "30SP" +Android:background= "#0000ff" -Android:text= "Two" +android:layout_weight= "2"/> A</LinearLayout>
3.mainactivity.java
1 @Override 2 protected void onCreate (Bundle savedinstancestate) {3 Super . OnCreate (savedinstancestate); 4 Setcontentview (r.layout.layout_weight_layout);
Android_mars Learning Notes _s01_007linear_layout nesting and layout_weight settings