Android "layout Manager"--Linear layout linearlayout

Source: Internet
Author: User

LinearLayout is a linear layout control: It is either laterally arranged or vertically arranged

Decisive attribute: Must have!

Android:orientation:vertical (vertical direction), horizontal (horizontal)

Common Properties:

Android:gravity------------Set the content location above the control itself

Android:layout_gravity-----Sets the display position of the control itself relative to the parent control

Android:layout_weight-----Assigning remaining space to a control

Example of vertical arrangement:

<span style= "Font-family:comic Sans ms;font-size:18px;" ><?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/ Res/android "    android:layout_width=" match_parent "    android:layout_height=" match_parent "    android:o rientation= "vertical" ><button     android:layout_width= "match_parent" android:layout_height= "Wrap_    Content "    android:text=" button 1 "    /><button     android:layout_width=" match_parent "    android:layout _height= "Wrap_content"    android:text= "button 2"    /><button     android:layout_width= "Match_parent"    android:layout_height= "wrap_content"    android:text= "button 3"    /><button     Android:layout_ Width= "Match_parent"    android:layout_height= "wrap_content"    android:text= "button 4"    /></ Linearlayout></span>


Example of horizontal arrangement:

<span style= "Font-family:comic Sans ms;font-size:18px;" ><?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/ Res/android "    android:layout_width=" match_parent "    android:layout_height=" match_parent "    android:o rientation= "Horizontal" ><button     android:layout_width= "wrap_content" android:layout_height= "Wrap_    Content "    android:text=" button 1 "    /><button     android:layout_width=" wrap_content "    android:layout _height= "Wrap_content"    android:text= "button 2"    /><button     android:layout_width= "Wrap_content"    android:layout_height= "wrap_content"    android:text= "button 3"    /><button     Android:layout_ Width= "Wrap_content"    android:layout_height= "wrap_content"    android:text= "button 4"    /></ Linearlayout></span>


Nested linear layouts:

<span style= "Font-family:comic Sans ms;font-size:18px;" ><?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/ Res/android "    android:layout_width=" match_parent "    android:layout_height=" match_parent "    android:o rientation= "Horizontal" >        <linearlayout >        ...      </LinearLayout>            <LinearLayout>        ..    </LinearLayout>    </LinearLayout></span>


Android "layout Manager"--Linear layout linearlayout

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.