Package icyllis.modernui.widget

# Class GridLayout.LayoutParams

java.lang.Object
icyllis.modernui.view.ViewGroup.LayoutParams
icyllis.modernui.view.ViewGroup.MarginLayoutParams
icyllis.modernui.widget.GridLayout.LayoutParams

Enclosing class:
  `GridLayout`

public static class GridLayout.LayoutParams extends ViewGroup.MarginLayoutParams
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 `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 the `ViewGroup.LayoutParams.width` and `ViewGroup.LayoutParams.height` properties are both `ViewGroup.LayoutParams.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 `ViewGroup.LayoutParams.MATCH_PARENT` from `ViewGroup.LayoutParams.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

- `ViewGroup.LayoutParams.width` = `ViewGroup.LayoutParams.WRAP_CONTENT`
- `ViewGroup.LayoutParams.height` = `ViewGroup.LayoutParams.WRAP_CONTENT`
- `ViewGroup.MarginLayoutParams.topMargin` = 0 when `useDefaultMargins` is `false`; otherwise `GridLayout.UNDEFINED`, to indicate that a default value should be computed on demand.
- `ViewGroup.MarginLayoutParams.leftMargin` = 0 when `useDefaultMargins` is `false`; otherwise `GridLayout.UNDEFINED`, to indicate that a default value should be computed on demand.
- `ViewGroup.MarginLayoutParams.bottomMargin` = 0 when `useDefaultMargins` is `false`; otherwise `GridLayout.UNDEFINED`, to indicate that a default value should be computed on demand.
- `ViewGroup.MarginLayoutParams.rightMargin` = 0 when `useDefaultMargins` is `false`; otherwise `GridLayout.UNDEFINED`, to indicate that a default value should be computed on demand.
- `rowSpec``.row` = `GridLayout.UNDEFINED`
- `rowSpec``.rowSpan` = 1
- `rowSpec``.alignment` = `GridLayout.BASELINE`
- `rowSpec``.weight` = 0
- `columnSpec``.column` = `GridLayout.UNDEFINED`
- `columnSpec``.columnSpan` = 1
- `columnSpec``.alignment` = `GridLayout.START`
- `columnSpec``.weight` = 0

See `GridLayout` for a more complete description of the conventions used by GridLayout in the interpretation of the properties of this class.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `GridLayout.Spec`
  `columnSpec`
  The spec that defines the horizontal characteristics of the cell group described by these layout parameters.
  `GridLayout.Spec`
  `rowSpec`
  The spec that defines the vertical characteristics of the cell group described by these layout parameters.

  ### Fields inherited from class icyllis.modernui.view.ViewGroup.MarginLayoutParams

  `bottomMargin, DEFAULT_MARGIN_RELATIVE, leftMargin, rightMargin, topMargin`

  ### Fields inherited from class icyllis.modernui.view.ViewGroup.LayoutParams

  `height, MATCH_PARENT, width, WRAP_CONTENT`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `LayoutParams()`
  Constructs a new LayoutParams with default values as defined in `GridLayout.LayoutParams`.
  `LayoutParams(ViewGroup.LayoutParams params)`
  `LayoutParams(ViewGroup.MarginLayoutParams params)`
  `LayoutParams(GridLayout.LayoutParams source)`
  Copy constructor.
  `LayoutParams(GridLayout.Spec rowSpec, GridLayout.Spec columnSpec)`
  Constructs a new LayoutParams instance for this `rowSpec` and `columnSpec`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object o)`
  `int`
  `hashCode()`
  `void`
  `setGravity(int gravity)`
  Describes how the child views are positioned.

  ### Methods inherited from class icyllis.modernui.view.ViewGroup.MarginLayoutParams

  `copyMarginsFrom, getLayoutDirection, getMarginEnd, getMarginStart, isLayoutRtl, isMarginRelative, onDebugDraw, resolveLayoutDirection, setLayoutDirection, setMarginEnd, setMargins, setMarginsRelative, setMarginStart`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### rowSpec

    public GridLayout.Spec rowSpec
    The spec that defines the vertical characteristics of the cell group described by these layout parameters. If an assignment is made to this field after a measurement or layout operation has already taken place, a call to `View.setLayoutParams(ViewGroup.LayoutParams)` must be made to notify GridLayout of the change. GridLayout is normally able to detect when code fails to observe this rule, issue a warning and take steps to compensate for the omission. This facility is implemented on a best effort basis and should not be relied upon in production code - so it is best to include the above calls to remove the warnings as soon as it is practical.

  - ### columnSpec

    public GridLayout.Spec columnSpec
    The spec that defines the horizontal characteristics of the cell group described by these layout parameters. If an assignment is made to this field after a measurement or layout operation has already taken place, a call to `View.setLayoutParams(ViewGroup.LayoutParams)` must be made to notify GridLayout of the change. GridLayout is normally able to detect when code fails to observe this rule, issue a warning and take steps to compensate for the omission. This facility is implemented on a best effort basis and should not be relied upon in production code - so it is best to include the above calls to remove the warnings as soon as it is practical.

- ## Constructor Details

  - ### LayoutParams

    public LayoutParams(GridLayout.Spec rowSpec, GridLayout.Spec columnSpec)
    Constructs a new LayoutParams instance for this `rowSpec` and `columnSpec`. All other fields are initialized with default values as defined in `GridLayout.LayoutParams`.
    Parameters:
      `rowSpec` - the rowSpec
      `columnSpec` - the columnSpec

  - ### LayoutParams

    public LayoutParams()
    Constructs a new LayoutParams with default values as defined in `GridLayout.LayoutParams`.

  - ### LayoutParams

    public LayoutParams(ViewGroup.LayoutParams params)

  - ### LayoutParams

    public LayoutParams(ViewGroup.MarginLayoutParams params)

  - ### LayoutParams

    public LayoutParams(GridLayout.LayoutParams source)
    Copy constructor. Clones the width, height, margin values, row spec, and column spec of the source.
    Parameters:
      `source` - The layout params to copy from.

- ## Method Details

  - ### setGravity

    public void setGravity(int gravity)
    Describes how the child views are positioned. Default is `LEFT | BASELINE`. See `Gravity`.
    Parameters:
      `gravity` - the new gravity value

  - ### equals

    public boolean equals(Object o)
    Overrides:
      `equals` in class `Object`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`