1. How do you control the relative position of a control in a parent control?
Layout_margin is provided in the Android system to control the margins of a control's edge relative to the parent control.
which
Android:layout_margintop represents the distance that a control is relative to the top of the parent control.
Android:layout_marginleft represents the distance of a control relative to the left border of the parent control.
Android:layout_marginright represents the distance of a control relative to the right border of the parent control.
Android:layout_marginbuttom represents the distance from the bottom of a control relative to the parent control.
2. How do you control the relative position of content in a control in the control?
Padding is provided in the Android system to control the margins of content in a control relative to the edge of the control.
which
Android:paddingtop represents the distance of content in a control relative to the top of the edge of the control.
Android:paddingleft represents the distance of content in a control relative to the left edge of the control.
Android:paddingright represents the distance of content in a control relative to the right edge of the control.
Android:paddingbuttom represents the distance of content in a control relative to the bottom of the control's edge.
3. The difference between android:gravity and android:layout_gravity
The android:gravity is used to set the alignment of the view component, and android:layout_gravity is used to set the alignment of the container component.
For example, Button:
Android:gravity: Indicates the position of the word above the button in the button,
Android:layout_gravity: Represents the position of the button on the interface.