In Android, there are 3 files that need to be noted: Main.axml,string.xml and Activity.cs.
1. layout file Main.axml, this file is saved in the Resouses/layout directory, which is also a directory where all layout files are used.
2. variable file String.xml
Some common common variables are saved in the file, and the corresponding values are assigned to those variables. These values are often strings and are used to display in some controls.
3. Logic implementation file Activity.cs
One: Linear layout linearlayout
Common Properties:
Control layout |
Property |
Value |
Note |
Vertical layout |
LinearLayout |
Orientation |
Vertical |
Indicates that the linear layout method is vertical |
Layout_width |
Fiil_parent |
Populating the parent container |
Layout_height |
Fill_parent |
Populating the parent container |
Background |
#FFFFFF |
The layout background is white |
Horizontal layout |
LinearLayout |
Orientation |
Horizontal |
Layout as horizontal line layout |
Second: relative layout relativelayout
The relative layout is used in two ways, one relative to the parent container's layout, and one for the relative layout of the controls.
A. Layout relative to the parent container
When using this layout, you need to use a key 8 properties for the layout, as follows:
Layout_marigntop: The distance from the top edge of the parent container to the topmost part of the control.
Layout_mariginbutton: The distance at the bottom of the control from the bottom of the parent container.
Layout_mariginright: Distance from the right edge of the parent container to the right of the control.
Layout_mariginleft: Distance from the left edge of the parent container to the left of the control.
Layout_alignparettop: The control is aligned with the top of the parent container, but first, the Layout_margintop value must be met.
Xamarin Learning page Layouts