public static class GridLayout.LayoutParams extends ViewGroup.MarginLayoutParams
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.
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
.
WRAP_CONTENT
or MATCH_PARENT
when configuring the children of
a GridLayout.
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
columnSpec
.column
= GridLayout.UNDEFINED
columnSpec
.columnSpan
= 1 columnSpec
.alignment
= GridLayout.START
GridLayout
for a more complete description of the conventions
used by GridLayout in the interpretation of the properties of this class.Modifier and Type | Field and 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.
|
bottomMargin, DEFAULT_RELATIVE, leftMargin, rightMargin, topMargin
FILL_PARENT, height, layoutAnimationParameters, MATCH_PARENT, width, WRAP_CONTENT
Constructor and Description |
---|
GridLayout.LayoutParams()
Constructs a new LayoutParams with default values as defined in
GridLayout.LayoutParams . |
GridLayout.LayoutParams(Context context,
AttributeSet attrs)
Values not defined in the attribute set take the default values
defined in
GridLayout.LayoutParams . |
GridLayout.LayoutParams(GridLayout.LayoutParams that) |
GridLayout.LayoutParams(GridLayout.Spec rowSpec,
GridLayout.Spec columnSpec)
Constructs a new LayoutParams instance for this
rowSpec
and columnSpec . |
GridLayout.LayoutParams(ViewGroup.LayoutParams params) |
GridLayout.LayoutParams(ViewGroup.MarginLayoutParams params) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o)
Compares this instance with the specified object and indicates if they
are equal.
|
int |
hashCode()
Returns an integer hash code for this object.
|
protected void |
setBaseAttributes(TypedArray attributes,
int widthAttr,
int heightAttr)
Extracts the layout parameters from the supplied attributes.
|
void |
setGravity(int gravity)
Describes how the child views are positioned.
|
getLayoutDirection, getMarginEnd, getMarginStart, isLayoutRtl, isMarginRelative, onDebugDraw, resolveLayoutDirection, setLayoutDirection, setMarginEnd, setMargins, setMarginsRelative, setMarginStart
debug, sizeToString
public GridLayout.Spec rowSpec
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.public GridLayout.Spec columnSpec
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.public GridLayout.LayoutParams(GridLayout.Spec rowSpec, GridLayout.Spec columnSpec)
rowSpec
and columnSpec
. All other fields are initialized with
default values as defined in GridLayout.LayoutParams
.rowSpec
- the rowSpeccolumnSpec
- the columnSpecpublic GridLayout.LayoutParams()
GridLayout.LayoutParams
.public GridLayout.LayoutParams(ViewGroup.LayoutParams params)
public GridLayout.LayoutParams(ViewGroup.MarginLayoutParams params)
public GridLayout.LayoutParams(GridLayout.LayoutParams that)
public GridLayout.LayoutParams(Context context, AttributeSet attrs)
GridLayout.LayoutParams
.public void setGravity(int gravity)
LEFT | BASELINE
.
See Gravity
.gravity
- the new gravity valueprotected void setBaseAttributes(TypedArray attributes, int widthAttr, int heightAttr)
ViewGroup.LayoutParams
setBaseAttributes
in class ViewGroup.LayoutParams
attributes
- the style attributes to extract the parameters fromwidthAttr
- the identifier of the width attributeheightAttr
- the identifier of the height attributepublic boolean equals(Object o)
Object
o
must represent the same object
as this instance using a class-specific comparison. The general contract
is that this comparison should be reflexive, symmetric, and transitive.
Also, no object reference other than null is equal to null.
The default implementation returns true
only if this ==
o
. See Writing a correct
equals
method
if you intend implementing your own equals
method.
The general contract for the equals
and Object.hashCode()
methods is that if equals
returns true
for
any two objects, then hashCode()
must return the same value for
these objects. This means that subclasses of Object
usually
override either both methods or neither of them.
equals
in class Object
o
- the object to compare this instance with.true
if the specified object is equal to this Object
; false
otherwise.Object.hashCode()
public int hashCode()
Object
Object.equals(java.lang.Object)
returns true
must return
the same hash code value. This means that subclasses of Object
usually override both methods or neither method.
Note that hash values must not change over time unless information used in equals comparisons also changes.
See Writing a correct
hashCode
method
if you intend implementing your own hashCode
method.
hashCode
in class Object
Object.equals(java.lang.Object)