LayoutParams
open class LayoutParams : MarginLayoutParams
kotlin.Any | |||
↳ | android.view.ViewGroup.LayoutParams | ||
↳ | android.view.ViewGroup.MarginLayoutParams | ||
↳ | androidx.gridlayout.widget.GridLayout.LayoutParams |
Layout information associated with each of the children of a GridLayout.
GridLayout supports both row and column spanning and arbitrary forms of alignment within each cell group. The fundamental parameters associated with each cell group are gathered into their vertical and horizontal components and stored in the rowSpec
and columnSpec
layout parameters. Specs
are immutable structures and may be shared between the layout parameters of different children.
The row and column specs contain the leading and trailing indices along each axis and together specify the four grid indices that delimit the cells of this cell group.
The alignment properties of the row and column specs together specify both aspects of alignment within the cell group. It is also possible to specify a child's alignment within its cell group by using the GridLayout.LayoutParams#setGravity(int)
method.
The weight property is also included in Spec and specifies the proportion of any excess space that is due to the associated view.
WRAP_CONTENT and MATCH_PARENT
Because the default values of thewidth
and height
properties are both WRAP_CONTENT
, this value never needs to be explicitly declared in the layout parameters of GridLayout's children. In addition, GridLayout does not distinguish the special size value MATCH_PARENT
from WRAP_CONTENT
. A component's ability to expand to the size of the parent is instead controlled by the principle of flexibility, as discussed in GridLayout
.
Summary
You should not need to use either of the special size values:WRAP_CONTENT
or MATCH_PARENT
when configuring the children of a GridLayout.
Default values
width
=WRAP_CONTENT
height
=WRAP_CONTENT
topMargin
= 0 whenuseDefaultMargins
isfalse
; otherwiseUNDEFINED
, to indicate that a default value should be computed on demand.leftMargin
= 0 whenuseDefaultMargins
isfalse
; otherwiseUNDEFINED
, to indicate that a default value should be computed on demand.bottomMargin
= 0 whenuseDefaultMargins
isfalse
; otherwiseUNDEFINED
, to indicate that a default value should be computed on demand.rightMargin
= 0 whenuseDefaultMargins
isfalse
; otherwiseUNDEFINED
, to indicate that a default value should be computed on demand.rowSpec
.row
=UNDEFINED
rowSpec
.rowSpan
= 1rowSpec
.alignment
=BASELINE
rowSpec
.weight
= 0columnSpec
.column
=UNDEFINED
columnSpec
.columnSpan
= 1columnSpec
.alignment
=START
columnSpec
.weight
= 0
GridLayout
for a more complete description of the conventions used by GridLayout in the interpretation of the properties of this class.
Summary
Public constructors | |
---|---|
<init>(rowSpec: GridLayout.Spec!, columnSpec: GridLayout.Spec!) Constructs a new LayoutParams instance for this |
|
<init>() Constructs a new LayoutParams with default values as defined in |
|
<init>(params: LayoutParams!) |
|
<init>(params: MarginLayoutParams!) |
|
<init>(source: GridLayout.LayoutParams!) Copy constructor. |
|
<init>(context: Context!, attrs: AttributeSet!) Values not defined in the attribute set take the default values defined in |
Public methods | |
---|---|
open Boolean | |
open Int |
hashCode() |
open Unit |
setGravity(gravity: Int) Describes how the child views are positioned. |
Protected methods | |
---|---|
open Unit |
setBaseAttributes(attributes: TypedArray!, widthAttr: Int, heightAttr: Int) |
Properties | |
---|---|
GridLayout.Spec! |
The spec that defines the horizontal characteristics of the cell group described by these layout parameters. |
GridLayout.Spec! |
The spec that defines the vertical characteristics of the cell group described by these layout parameters. |
Public constructors
<init>
LayoutParams(
rowSpec: GridLayout.Spec!,
columnSpec: GridLayout.Spec!)
Constructs a new LayoutParams instance for this rowSpec
and columnSpec
. All other fields are initialized with default values as defined in LayoutParams
.
Parameters | |
---|---|
rowSpec |
GridLayout.Spec!: the rowSpec |
columnSpec |
GridLayout.Spec!: the columnSpec |
<init>
LayoutParams(