Mono for Android Layout Control Properties Summary

Source: Internet
Author: User

1. Layout_weight is used to assign values to the importance of many views in a linear layout.
All views have a layout_weight value, which defaults to zero, meaning it needs to be displayed
How large a view occupies is the screen space. If you assign a value higher than zero, the parent view
The available space in the graph is split, and the split size depends on the layout_weight of each view
Value and the overall layout_weight value of the value in the current screen layout and the other view screen cloth
Percentage of the Layout_weight value of the bureau.
For example, let's say we have a text label and two text editing elements in the horizontal direction.
The text label does not specify a layout_weight value, so it will occupy the minimum space needed to provide it.
If the layout_weight value of each of the two text-editing elements is set to 1, the two are split equally
The remaining width in the parent view layout (because we declare the importance of the two equal). If two X
The text editing element where the first Layout_weight value is set to 1, and the second is set to 2,
The remaining space of two-thirds points to the first, One-third points to the second (the smaller the value, the higher the importance).
2.android:layout_below= "What do you Mean," @id/image_item?
This means that the current control is laid out under a control with an ID of Image_item
3. Android:gravity:
This is for the elements in the control, to control where the element is displayed in the control. For example, set the following two properties in a button control

Android:gravity= "left" and android:text= "submit", then the text "Submit" on the button will be on the right side of the button.
Android:layout_gravity:

This is for the control itself, which controls the position of the control in the parent control that contains the control. Similarly, when we set the android:layout_gravity= "left" property in the button control, it means that the button will be located at the right-hand side of the interface.
4. Relativelayout of the various properties in Android
Category: android-3g 2010-10-11 15:38 21756 people read reviews (10) Favorite reports
Androidlayout
Android:layout_above= "@id/xxx"-puts the control on top of the given ID control
android:layout_below= "@id/xxx"-places the control under the given ID control

android:layout_toleftof= "@id/xxx"-Aligns the right edge of the control with the left edge of the given ID control (that is, place the control to the left of the given ID, which can be anywhere on the left, for example, upper left)
android:layout_torightof= "@id/xxx"-aligns the left edge of the control with the right edge of the given ID control

android:layout_alignleft= "@id/xxx"-aligns the left edge of the control with the left edge of the given ID control (left-justified)
android:layout_aligntop= "@id/xxx"-aligns the top edge of the control with the top edge of the given ID control
android:layout_alignright= "@id/xxx"-Aligns the right edge of the control with the right edge of the given ID control
android:layout_alignbottom= "@id/xxx"-Aligns the bottom edge of the control with the bottom edge of the given ID control
Android:layout_alignparentleft= "true"-aligns the left edge of the control with the left edge of the parent control
Android:layout_alignparenttop= "true"-aligns the top edge of the control with the top edge of the parent control
Android:layout_alignparentright= "true"-aligns the right edge of the control with the right edge of the parent control
Android:layout_alignparentbottom= "true"-aligns the bottom edge of the control with the bottom edge of the parent control
Android:layout_centerinparent= "true"--places the control in the center of the parent control
Android:layout_centerhorizontal= "true"--places the control in the center of the horizontal direction
Android:layout_centervertical= "true"--places the control in the center of the vertical direction

5. The number of rows Tablelayout is directly specified by the developer, that is, how many TableRow objects (or view controls) there are.
The number of columns of tablelayout equals the number of columns of TableRow that contain the most child controls. If the first TableRow contains 2 child controls, the second TableRow contains 3, and the third TableRow contains 4, then the Tablelayout has a number of 4 columns.

Tablelayout properties that can be set include global properties and cell properties.
(1), the global attribute is also the column property, the following 3 parameters:
Android:stretchcolumns sets the columns that can be stretched. The column can stretch to the row direction, up to a full row.
Android:shrinkcolumns sets the columns that can be shrunk. When the column control has too much content and is already packed in the row, the contents of the child control are displayed in the columns direction.
Android:collapsecolumns sets the columns to hide.

Example:
android:stretchcolumns= "0" No. 0 column extendable
Android:shrinkcolumns= 1th, 2 columns can be shrunk
android:collapsecolumns= "*" hides all rows
Note: Columns can have both the Stretchcolumns and Shrinkcolumns properties, so if the column has more than N, "multiline" displays its contents. (This is not really multiple lines, but the system automatically adjusts the line's layout_height as needed)
(2), cell properties, with the following 2 parameters:
Android:layout_column specifies that the cell is displayed in the first column
ANDROID:LAYOUT_SPAN Specifies the number of columns that the cell occupies (when unspecified, 1)
Example:
android:layout_column= "1" The control is displayed in the 1th column
Android:layout_span= "2" This control occupies 2 columns
Description: A control can also have both features.
For details, please see http://blog.csdn.net/zj0078/article/details/7390505


Gridview:
Android:numcolumns= "Auto_fit", the GridView column number is set to Automatic
Android:verticalspacing= "10DP", margin between two lines
Android:stretchmode= "ColumnWidth", Zoom and column size synchronization
android:horizontalspacing spacing between columns of two

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.