Activity contains Views and ViewGroups. Examples of widgets are buttons, labels, text boxes, etc. One or more Views can be grouped together into a ViewGroup. A ViewGroup provides the layout in which you can order the appearance and sequence of views. Examples of View groups are LinearLayout, Relative Layout, etc. A
ViewGroup derives from the base class android.view.ViewGroup.
The
LinearLayout arranges views in a single column or a single row. It displays child View elements in a linear direction, either vertically or horizontally. Like a box, it contains controls inside. Controls are drawn one after another either horizontally or vertically according to the orientation of the layout.
When dealing with a linear layout there are five properties that we can deal with:
- Orientation
- Fill model
- Weight
- Gravity
- padding
The Common attributes supported by views and viewgroups are:
| Attribute | Description |
| layout_gravity | Declare child Views position |
| layout_weight | Declare the extra space in the layout which to be allocated to the View |
| layout_marginRight | Declare extra space on the right side of the View |
| layout_marginLeft | Declare extra space on the left side of the View |
| layout_marginBottom | Declare extra space on the bottom side of the View |
| layout_x | Declare the x-coordinate of the View |
| layout_y | Declare the y-coordinate of the View |
| layout_marginTop | Declare extra space on the top side of the View |
| layout_width | Declare the width of the View |
| layout_height | Declare the height of the View |









Join the conversation! Your thoughts help the community grow.