Android Learning--linearlayout layout for center, left, right-justified

Source: Internet
Author: User

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

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.