Android layout manager (Linear layout)

Source: Internet
Author: User

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:

  1. 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> 

  2. 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)

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.