Android UI Layouts Tutorial with Examples
- The standard Layouts:
LinearLayout is a view group that aligns all children in a single direction, vertically or horizontally.
RelativeLayout is a view group that displays child views in relative positions.
TableLayout is a view that groups views into rows and columns.
||GridLayout uses a grid of infinitely-thin lines to separate its drawing area into: rows, columns, and cells. It supports both row and column spanning, which together allow a widget to occupy a rectangular range of cells that are next to each other.|
The FrameLayout is a placeholder on screen that you can use to display a single view.
AbsoluteLayout enables you to specify the exact location of its children. Arrange the children views according coordinates x, y.
- The standard Containers:
The flexibility of columns is inferred from the gravity of the components inside the column. If every component defines a gravity, the column is taken as flexible, otherwise the column is considered inflexible
Note: If the root element of the interface is not GridLayout, you can change the name of card without having to change anything else, so you will have an interface with the root element is GridLayout.
If you specify a value different than 0 for layout_columnWeight, you need to set layout_gravity value for the object, this is mandatory, if not specify the layout_gravity value, object can not be displayed on the grid:
- The value for layout_gravity in this case is: