Application of Android Development--linearlayout

Source: Internet
Author: User
<span id="Label3"></p><p><p>1. Introduction</p></p><p><p>LinearLayout is the linear layout in the three most common layouts for ANDROID. Among them, linear layout is divided into horizontal line layout and vertical linear Layout. The views are as Follows:</p></p><p><p></p></p><p><p>Horizontal layout</p></p><p><p></p></p><p><p>Vertical layout</p></p><p><p>2. Build</p></p><p><p>In the Android layout, we often need to nest the layout, for example</p></p><p><p></p></p><p><p></p></p><p><p>The focus is as Follows:</p></p><p><p><strong>2.1 <span style="font-size: 12px;">android:orientation= "horizontal/ertical": This property indicates that the layout is horizontal or vertical. </span></strong></p></p><p><p><span style="font-size: 12px;"><strong>2.2 android:layout_weight= "A": This property represents the size of the total layout of a child layout, all sub-layout numbers are combined with sum (a), and the number of sub-layouts a/sum (a) is the Percentage.</strong></span></p></p><p><p><strong><span style="font-size: 14px;">2.3 <span style="font-size: 12px;">android:gravity= "start/center/end/bottom": This property indicates where the part in the layout <strong><span style="font-size: 14px;"><span style="font-size: 12px;">starts horizontally</span></span></strong> , centered, ends in horizontal orientation, or at the Bottom. </span></span></strong></p></p><p><span style="font-size: 12px;"><span style="font-size: 12px;"><linearlayout xmlns:android= "http://schemas.android.com/apk/res/android"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">xmlns:tools= "http://schemas.android.com/tools"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:id= "@+id/linearlayout1"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:layout_width= "match_parent"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:layout_height= "match_parent"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;"> <span style="background-color: #99ccff;">android:orientation= "vertical"</span> </span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:paddingbottom= "@dimen/activity_vertical_margin"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:paddingleft= "@dimen/activity_horizontal_margin"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:paddingright= "@dimen/activity_horizontal_margin"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:paddingtop= "@dimen/activity_vertical_margin"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">tools:context= "example.linearlayout.Activity1" ></span></span><br><br><span style="font-size: 12px;"><span style="font-size: 12px;"><linearlayout</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:layout_width= "fill_parent"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:layout_height= "wrap_content"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:orientation= "horizontal"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;"> <span style="background-color: #99ccff;">android:layout_weight= "1"</span> ></span></span><br><br><span style="font-size: 12px;"><span style="font-size: 12px;"><button</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:id= "@+id/button1"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:layout_width= "wrap_content"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:layout_height= "wrap_content"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:text= "@string/bu1"/></span></span><br><br><span style="font-size: 12px;"><span style="font-size: 12px;"><linearlayout</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:layout_width= "fill_parent"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:layout_height= "wrap_content"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:orientation= "vertical"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;"> <span style="background-color: #99ccff;">android:gravity= "end"</span> ></span></span><br><br><span style="font-size: 12px;"><span style="font-size: 12px;"><button</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:id= "@+id/button2"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:layout_width= "wrap_content"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:layout_height= "wrap_content"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:text= "@string/bu2"/></span></span><br><br><span style="font-size: 12px;"><span style="font-size: 12px;"></LinearLayout></span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;"></LinearLayout></span></span><br><br><span style="font-size: 12px;"><span style="font-size: 12px;"><linearlayout</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:layout_width= "match_parent"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:layout_height= "wrap_content"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:orientation= "vertical"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;"> <span style="background-color: #99ccff;">android:gravity= "center"</span> </span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:layout_weight= "1" ></span></span><br><br><span style="font-size: 12px;"><span style="font-size: 12px;"><button</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:id= "@+id/button3"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:layout_width= "wrap_content"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:layout_height= "wrap_content"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:text= "@string/bu3"/></span></span><br><br><span style="font-size: 12px;"><span style="font-size: 12px;"></LinearLayout></span></span><br><br><span style="font-size: 12px;"><span style="font-size: 12px;"><linearlayout</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:layout_width= "match_parent"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:layout_height= "wrap_content"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:orientation= "horizontal"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:layout_weight= "1"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;"> <span style="background-color: #99ccff;">android:gravity= "bottom"</span> > <span style="color: #00ccff;">//it puts its parts at the bottom, so its sub-layout will also be the bottom, as shown in the last</span> </span> picture</span><br><br><span style="font-size: 12px;"><span style="font-size: 12px;"><button</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:id= "@+id/button5"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:layout_width= "wrap_content"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:layout_height= "wrap_content"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:text= "@string/bu5"/></span></span><br><br><span style="font-size: 12px;"><span style="font-size: 12px;"><linearlayout</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:layout_width= "fill_parent"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:layout_height= "wrap_content" <span style="color: #00ccff;">//here height adjusts to adaptive, so that its height is consistent with the button height</span> </span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:orientation= "vertical"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;"> <span style="background-color: #99ccff;">android:gravity= "end"</span>></span></span><br><br><span style="font-size: 12px;"><span style="font-size: 12px;"><button</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:id= "@+id/button4"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:layout_width= "wrap_content"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:layout_height= "wrap_content"</span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;">android:text= "@string/bu4"/></span></span><br><br><span style="font-size: 12px;"><span style="font-size: 12px;"></LinearLayout></span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;"></LinearLayout></span></span><br><span style="font-size: 12px;"><span style="font-size: 12px;"></LinearLayout></span></span><br><br></p><p><p></p></p><p><p>Application of Android Development--linearlayout</p></p></span>

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.