Linear layout: LinearLayout and linear linearlayout

Source: Internet
Author: User

Linear layout: LinearLayout and linear linearlayout
Linear layout LinearLayout

I. Introduction

LinearLayout is a linear layout. The components in the LinearLayout layout container are arranged one by one: you can not only control the horizontal arrangement of components, but also control the vertical arrangement of each component. Use the orientation attribute to set whether the linear arrangement is vertical or horizontal ).

 

Linear layout example

 

Ii. code example

:

Structure

 

Code:

/Test_LinearLayout/res/layout/activity_main.xml

Android: layout_weight = "4"
Weight
Android: gravity = "bottom | right"
Bottom right of font
Android: orientation = "vertical">
Vertical layout

Xmlns: android = "http://schemas.android.com/apk/res/android"
Namespace

1 <? Xml version = "1.0" encoding = "UTF-8"?> 2 <LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" 3 android: layout_width = "match_parent" 4 android: layout_height = "match_parent" 5Android: orientation = "vertical">6 <! -- Input box --> 7 <EditText 8 android: id = "@ + id/editText_input" 9 android: layout_width = "match_parent" 10 android: layout_height = "wrap_content" 11Android: gravity = "bottom | right"12 13 android: text = "" 14Android: layout_weight = "4"15Android: textSize = "@ dimen/fontSize_num"16/> 17 18 <! -- Intermediate key area --> 19 <LinearLayout 20 android: layout_width = "match_parent" 21 android: layout_height = "wrap_content" 22 android: orientation = "vertical" 23 android: layout_weight = "12" 24 25> 26 <! -- Intermediate key area: Row 1 --> 27 <LinearLayout 28 android: layout_width = "match_parent" 29 android: layout_height = "wrap_content" 30 android: orientation = "horizontal" 31 android: layout_weight = "1" 32 33> 34 <Button 35 android: id = "@ + id/btn_num7" 36 android: layout_width = "wrap_content" 37 android: layout_height = "wrap_content" 38 android: text = "7" 39 android: layout_weight = "2" 40 android: textSize = "@ dimen/fontSize_num" 41/> 42 <Button 43 android: id = "@ + id/btn_num8" 44 android: layout_width = "wrap_content" 45 android: layout_height = "wrap_content" 46 android: text = "8" 47 android: layout_weight = "2" 48 android: textSize = "@ dimen/fontSize_num" 49/> 50 <Button 51 android: id = "@ + id/btn_num9" 52 android: layout_width = "wrap_content" 53 android: layout_height = "wrap_content" 54 android: text = "9" 55 android: layout_weight = "2" 56 android: t ExtSize = "@ dimen/fontSize_num" 57/> 58 <Button 59 android: id = "@ + id/btn_symbol_divide" 60 android: layout_width = "wrap_content" 61 android: layout_height = "wrap_content" 62 android: text = "/" 63 android: layout_weight = "2" 64 android: textSize = "@ dimen/fontSize_num" 65/> 66 </LinearLayout> 67 68 <! -- Intermediate key area: Second row --> 69 <LinearLayout 70 android: layout_width = "match_parent" 71 android: layout_height = "wrap_content" 72 android: orientation = "horizontal" 73 android: layout_weight = "1" 74 android: textSize = "@ dimen/fontSize_num" 75> 76 <Button 77 android: id = "@ + id/btn_num4" 78 android: layout_width = "wrap_content" 79 android: layout_height = "wrap_content" 80 android: text = "4" 81 android: layout_weight = "2" 82 android Oid: textSize = "@ dimen/fontSize_num" 83/> 84 <Button 85 android: id = "@ + id/btn_num5" 86 android: layout_width = "wrap_content" 87 android: layout_height = "wrap_content" 88 android: text = "5" 89 android: layout_weight = "2" 90 android: textSize = "@ dimen/fontSize_num" 91/> 92 <Button 93 android: id = "@ + id/btn_num6" 94 android: layout_width = "wrap_content" 95 android: layout_height = "wrap_content" 96 android: text = "6" 97 Android: layout_weight = "2" 98 android: textSize = "@ dimen/fontSize_num" 99/> 100 <Button101 android: id = "@ + id/btn_symbol_multiply" 102 android: layout_width = "wrap_content" 103 android: layout_height = "wrap_content" 104 android: text = "*" 105 android: layout_weight = "2" 106 android: textSize = "@ dimen/fontSize_num" 107/> 108 </LinearLayout> 109 110 <! -- Intermediate key area: Row 3 --> 111 <LinearLayout112 android: layout_width = "match_parent" 113 android: layout_height = "wrap_content" 114 android: orientation = "horizontal" 115 android: layout_weight = "1" 116 android: textSize = "@ dimen/fontSize_num" 117> 118 <Button119 android: id = "@ + id/btn_num1" 120 android: layout_width = "wrap_content" 121 android: layout_height = "wrap_content" 122 android: text = "1" 123 android: layout_weight = "2" 124 android Oid: textSize = "@ dimen/fontSize_num" 125/> 126 <Button127 android: id = "@ + id/btn_num2" 128 android: layout_width = "wrap_content" 129 android: layout_height = "wrap_content" 130 android: text = "2" 131 android: layout_weight = "2" 132 android: textSize = "@ dimen/fontSize_num" 133/> 134 <Button135 android: id = "@ + id/btn_num3" 136 android: layout_width = "wrap_content" 137 android: layout_height = "wrap_content" 138 android: text = "3" 139 Android: layout_weight = "2" 140 android: textSize = "@ dimen/fontSize_num" 141/> 142 <Button143 android: id = "@ + id/btn_symbol_subtract" 144 android: layout_width = "wrap_content" 145 android: layout_height = "wrap_content" 146 android: text = "-" 147 android: layout_weight = "2" 148 android: textSize = "@ dimen/fontSize_num" 149/> 150 </LinearLayout> 151 152 <! -- Intermediate key area: Row 4 --> 153 <LinearLayout154 android: layout_width = "match_parent" 155 android: layout_height = "wrap_content" 156 android: orientation = "horizontal" 157 android: layout_weight = "1" 158> 159 <Button160 android: id = "@ + id/btn_num0" 161 android: layout_width = "wrap_content" 162 android: layout_height = "wrap_content" 163 android: text = "0" 164 android: layout_weight = "2" 165 android: textSize = "@ dimen/fontSize_num" 166/> 16 7 <Button168 android: id = "@ + id/btn_symbol_point" 169 android: layout_width = "wrap_content" 170 android: layout_height = "wrap_content" 171 android: text = ". "172 android: layout_weight =" 2 "173 android: textSize =" @ dimen/fontSize_num "174/> 175 <Button176 android: id =" @ + id/btn_symbol_add "177 android: layout_width = "wrap_content" 178 android: layout_height = "wrap_content" 179 android: text = "+" 180 android: layout_weight = "2" 18 1 android: textSize = "@ dimen/fontSize_num" 182/> 183 <Button184 android: id = "@ + id/btn_symbol_equal" 185 android: layout_width = "wrap_content" 186 android: layout_height = "wrap_content" 187 android: text = "=" 188 android: layout_weight = "2" 189 android: textSize = "@ dimen/fontSize_num" 190/> 191 </LinearLayout> 192 193 194 </LinearLayout> 195 196 <! -- Bottom clear area --> 197 <Button198 android: id = "@ + id/btn_clear" 199 android: layout_width = "match_parent" 200 android: layout_height = "wrap_content" 201 android: text = "clear" 202 android: layout_weight = "2" 203 android: textSize = "@ dimen/fontSize_num" 204/> 205 206 </LinearLayout> 207

 

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.