android:orientation= "vertical" means that the elements under this layout are arranged vertically;
To achieve an internal horizontal arrangement based on the overall vertical arrangement, create a linearlayout layout under the overall linearlayout layout.
1<?xml version= "1.0" encoding= "Utf-8"?>2<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"3android:orientation= "Vertical"4Android:id= "@+id/activity_main"5Android:layout_width= "Match_parent"6android:layout_height= "Match_parent" >7 8 9<TextViewTenAndroid:id= "@+id/textview" OneAndroid:layout_width= "Match_parent" Aandroid:layout_height= "Wrap_content" -android:text= "Total" -Android:textsize= "20SP" theandroid:gravity= "Center" -/> - -<TextView +Android:id= "@+id/textview2" -Android:layout_width= "Match_parent" +android:layout_height= "Wrap_content" Aandroid:text= "1619 Yuan" atAndroid:textsize= "20SP" -android:gravity= "Center" -android:layout_margintop= "23DP" -/> - -<LinearLayout inAndroid:layout_width= "Fill_parent"//Under this linearlayout, the default horizontal is not specified orientation -android:layout_height= "Wrap_content" toandroid:layout_margintop= "23DP" +> -<TextView theAndroid:layout_width= "Wrap_content" *android:layout_height= "Wrap_content" $Android:text= "Total Mileage:"Panax Notoginseng/> - the<TextView +Android:layout_width= "Match_parent" Aandroid:layout_height= "Wrap_content" theAndroid:gravity= "Right" +android:text= "266.86 km" -Android:id= "@+id/textview3" $/> $</LinearLayout> - -<LinearLayout theAndroid:layout_width= "Fill_parent" -android:layout_height= "Wrap_content"Wuyiandroid:layout_margintop= "23DP" > the<TextView -Android:layout_width= "Wrap_content" Wuandroid:layout_height= "Wrap_content" -android:text= "Freight:"/> About<TextView $Android:layout_width= "Match_parent" -android:layout_height= "Wrap_content" -Android:gravity= "Right" -Android:textcolor= "@color/coloraccent" Aandroid:text= "1639 Yuan" +/> the</LinearLayout> - $<LinearLayout theAndroid:layout_width= "Fill_parent" theandroid:layout_height= "Wrap_content" theandroid:layout_margintop= "23DP" > the<TextView -Android:layout_width= "Wrap_content" inandroid:layout_height= "Wrap_content" theandroid:text= "Starting price (including 5 km):"/> the<TextView AboutAndroid:layout_width= "Match_parent" theandroid:layout_height= "Wrap_content" theAndroid:gravity= "Right" theandroid:text= "1571 Yuan" +/> -</LinearLayout> the Bayi</LinearLayout>
The implementation results are as follows:
Android Learning--linearlayout layout for center, left, right-justified