GridLayout
GridLayout
places elements on a grid.
GridLayout
covers its entire surface with cells. Cells are not aligned. The elements constituting the cells will be stretched inside their allocated space, unless their size constraints—like, e.g., min-height
or max-width
—work against this.
Spacing properties
spacing
type: length
default: 0px
The distance between the elements in the layout. This single value is applied to both horizontal and vertical spacing.
To target specific axis with different values use the following properties:
spacing-horizontal
type: length
default: 0px
spacing-vertical
type: length
default: 0px
Padding properties
padding
type: length
default: 0px
The padding around the grid structure as a whole. This single value is applied to all sides.
To target specific sides with different values use the following properties:
padding-left
type: length
default: 0px
padding-right
type: length
default: 0px
padding-top
type: length
default: 0px
padding-bottom
type: length
default: 0px
Cell elements
Cell elements inside a GridLayout
obtain the following new properties. Any bindings to these properties must be compile-time constants:
row
type: int
default: 0
The index of the element’s row within the grid. Setting this property resets the element’s column to zero, unless explicitly set.
col
type: int
default: 0
The index of the element’s column within the grid. Set this property to override the sequential column assignment (e.g., to skip a column).
rowspan
type: int
default: 1
The number of rows this element should span.
colspan
type: int
default: 1
The number of columns this element should span.
To implicitly sequentially assign row indices—just like with col
—wrap cell elements in Row
elements.
The following example creates a 2-by-2 grid with Row
elements, omitting one cell:
The following example creates the same grid using the row
property. Row indices must be taken care of manually: