Learn the path of Android development (a) page layout
Source: Internet
Author: User
<span id="Label3"></p><p><p><span style="font-size: 18px">Android Page Layout</span></p></p><p><p><span style="font-size: 18px">The 1.Android page layout is divided into 6 categories:</span></p></p><p><p><span style="font-size: 18px">LinearLayout (linear layout), relativelayout (relative layout), tablelayout (table layout), framelayout (frame layout), GridLayout (grid layout), absolutelayout ( Absolute Layout)</span></p></p><p><p><span style="font-size: 18px">Commonly used for: linear layout and relative layout</span></p></p><p><p><span style="font-size: 18px">2. Features of the layout</span></p></p><p><p>Framelayout Frame Layout</p></p> <ul> <ul> <li>Layout Features: All the elements placed in it are placed in the leftmost area and cannot be assigned an exact position, and the next child element overlaps the previous child element</li> <li>Application scenario: suitable for viewing a single picture.</li> </ul> </ul><p><p>LinearLayout Linear layout</p></p> <ul> <ul> <li>Layout Features: A model that provides a horizontal or vertical arrangement of controls, with each sub-component<br>are arranged linearly in a vertical or horizontal manner. (default is Vertical)</li> <li>Application scenario: The most common layout method</li> </ul> </ul> <blockquote> <blockquote> <p>There is an important attribute android:layout_weight= "1" in the linearlayout, which represents the line spacing when vertical layout, the column width when horizontal, the larger the weight Value.</p> </blockquote> </blockquote><p><p>Absolutelayout Absolute Positioning layout</p></p> <ul> <ul> <li>Layout features: positioning the component in the way of the axis, the upper left corner is (0,0) point, to the right x axis increment, down the y axis increment, the Component positioning property is android:layout_x and android:layout_y to determine the Coordinates.</li> <li>Application Scenario: accurate positioning of spatial locations</li> </ul> </ul> <blockquote> <blockquote> <p>The layout is outdated due to the large differences in screen size and resolution of the Android phone and the inability to use absolutelayout to accommodate the adaptation problem</p> </blockquote> </blockquote><p><p>Relativelayout Relative layout</p></p> <ul> <ul> <li>Layout features: for a component as a reference, to locate the location of the next component layout Method.</li> <li>Scenario: A corresponding relationship exists between controls (suitable artifact, Recommended)</li> </ul> </ul><p><p>Tablelayout Table Layout</p></p> <ul> <ul> <li>Layout features: like table in html. use TableRow to layout, where TableRow represents a row, and each view component of TableRow represents a Cell.</li> <li>Scenario: A corresponding relationship exists between controls.</li> </ul> </ul><p><p>These five layout elements can be nested within each other to make an aesthetically pleasing interface.</p></p><p><p><span style="font-size: 18px">3. Common Properties of layouts</span></p></p> <ul> <ul> <li>Layout_width & Layout_height {xxxpd,wrap_content,match_parent,}</li> <li>layout_margin+ Azimuth & padding+ Azimuth</li> <li>Layout_gravity & Gravity</li> </ul> </ul><p><p><span style="color: #00ff00; background-color: #c0c0c0"><span style="color: #3366ff">wrap_content: the width and height of the corresponding view will be set to the minimum size required to fit the contents of the View</span></span></p></p><p><p><span style="background-color: #c0c0c0; color: #3366ff">Match_parent: the width and height of the view extends to the full parent layout</span></p></p><p><p><span style="background-color: #c0c0c0; color: #3366ff">Margin and padding differences: margin margins, padding padding and HTML usage</span></p></p><p><p><span style="background-color: #c0c0c0; color: #3366ff">Layout_gravity and gravity: used to determine where the view is docked in layout</span></p></p><p><p><span style="background-color: #c0c0c0; color: #3366ff">Layout_gravity and Gravity Differences:</span></p></p><p><p><span style="background-color: #c0c0c0; color: #3366ff">Gravity property: is the setting for the location of the view Content. For example, a button above the Text. You can set the text on the left side of the view, on the right, etc position</span></p></p><p><p><span style="background-color: #c0c0c0; color: #3366ff">Layout_gravity Property: is the position used to set the view relative to the parent view. <em id="__mceDel"> <em id="__mceDel">for example, a button in linearlayout, you can set this property to put the button in the parent layout linearlayout left to right and so On. </em></em></span></p></p><p><p><span style="background-color: #c0c0c0; color: #3366ff"><em><em>=============================================================================================================== =====================</em></em></span></p></p><p><p></p></p><p><p><strong>LinearLayout</strong></p></p><p><p>Orientation:vertical (vertical arrangement)/horizontal (horizontal)</p></p><p><p>Layout_weight: is a unique proportional distribution property of linear layout (linelayout). Use this property to set weights, and then to scale the spatial allocation of the interface, the formula is calculated: control width = Control set width + remaining space% wide</p></p><p><p><span style="color: #333333"></span></p></p>Relativelayout<p><p>A. Relative to the parent space</p></p> <table> <thead> <tr> <th>XML Properties</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Layout_alignparentbottom</td> <td>Aligns the bottom of the current control with the bottom of the parent control</td> </tr> <tr> <td>Layout_alignparentleft</td> <td>Aligns the left of the current control to the left of the parent control</td> </tr> <tr> <td>Layout_alignparentright</td> <td>Aligns the right end of the current control to the right side of the parent control</td> </tr> <tr> <td>Layout_alignparenttop</td> <td>Aligns the upper end of the current control with the top of the parent control</td> </tr> <tr> <td>Layout_centerhorizontal</td> <td>The current control is in the middle of the horizontal center of the parent control (in the middle of the horizontal Direction)</td> </tr> <tr> <td>Layout_centervertical</td> <td>The current control is in the vertical middle position of the parent control (right middle of the plane)</td> </tr> <tr> <td>Layout_centerinparent</td> <td>The current control is in the middle of the vertical direction of the parent control (in the middle Vertically)</td> </tr> </tbody> </table><p><p>All of the above properties are evaluated as Boolean: true, False.</p></p><p><p>B. Relative to a given control</p></p> <table> <thead> <tr> <th>XML Properties</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Layout_above</td> <td>Causes the current control to be positioned above the given ID control</td> </tr> <tr> <td>Layout_below</td> <td>Causes the current control to be located below the given ID control</td> </tr> <tr> <td>Layout_toleftof</td> <td>Causes the current control to be positioned to the left of the given ID control</td> </tr> <tr> <td>Layout_torightof</td> <td>Causes the current control to be positioned to the right of the given ID control</td> </tr> <tr> <td>Layout_alignbottom</td> <td>To overlap the current control with the bottom part of the given ID control</td> </tr> <tr> <td>Layout_alignleft</td> <td>Coincident the current control to the left of the given ID control</td> </tr> <tr> <td>Layout_alignright</td> <td>Coincident the current control to the right of the given ID control</td> </tr> <tr> <td>Layout_aligntop</td> <td>To make the current control coincide with the top of the given ID control</td> </tr> <tr> <td>Layout_alignbaseline</td> <td>Overlaps the baseline of the current control with the baseline of the given ID control t</td> </tr> </tbody> </table><p><p>The values for all of the above properties are the ID names of the given control, as in the following example</p></p><pre class="brush:html;gutter:true;"><pre class="brush:html;gutter:true;">The text control @+id/tab_textview under the control @+id/tab_imageview <textview android:id= "@+id/tab_textview" android: layout_below= "@+id/tab_imageview" android:layout_width= "wrap_content" android:layout_height= "wrap_ Content " /></pre></pre><p><p> </p></p><p><p>Learn the path of Android development (a) page layout</p></p></span>
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