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.
The weight property is also included in Spec and specifies the proportion of any excess space that is due to the associated view.
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
rowSpec
.weight
= 0 columnSpec
.column
= GridLayout.UNDEFINED
columnSpec
.columnSpan
= 1 columnSpec
.alignment
= GridLayout.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.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_MARGIN_RELATIVE, leftMargin, rightMargin, topMargin
FILL_PARENT, height, layoutAnimationParameters, MATCH_PARENT, width, WRAP_CONTENT
Constructor and Description |
---|
LayoutParams()
Constructs a new LayoutParams with default values as defined in
GridLayout.LayoutParams . |
LayoutParams(Context context,
AttributeSet attrs)
Values not defined in the attribute set take the default values
defined in
GridLayout.LayoutParams . |
LayoutParams(GridLayout.LayoutParams source)
Copy constructor.
|
LayoutParams(GridLayout.Spec rowSpec,
GridLayout.Spec columnSpec)
Constructs a new LayoutParams instance for this
rowSpec
and columnSpec . |
LayoutParams(ViewGroup.LayoutParams params) |
LayoutParams(ViewGroup.MarginLayoutParams params) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o)
Indicates whether some other object is "equal to" this one.
|
int |
hashCode()
Returns a hash code value for the 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.
|
copyMarginsFrom, encodeProperties, 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 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 LayoutParams()
GridLayout.LayoutParams
.public LayoutParams(ViewGroup.LayoutParams params)
public LayoutParams(ViewGroup.MarginLayoutParams params)
public LayoutParams(GridLayout.LayoutParams source)
source
- The layout params to copy from.public 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
The equals
method implements an equivalence relation
on non-null object references:
x
, x.equals(x)
should return
true
.
x
and y
, x.equals(y)
should return true
if and only if
y.equals(x)
returns true
.
x
, y
, and z
, if
x.equals(y)
returns true
and
y.equals(z)
returns true
, then
x.equals(z)
should return true
.
x
and y
, multiple invocations of
x.equals(y)
consistently return true
or consistently return false
, provided no
information used in equals
comparisons on the
objects is modified.
x
,
x.equals(null)
should return false
.
The equals
method for class Object
implements
the most discriminating possible equivalence relation on objects;
that is, for any non-null reference values x
and
y
, this method returns true
if and only
if x
and y
refer to the same object
(x == y
has the value true
).
Note that it is generally necessary to override the hashCode
method whenever this method is overridden, so as to maintain the
general contract for the hashCode
method, which states
that equal objects must have equal hash codes.
equals
in class Object
o
- the reference object with which to compare.true
if this object is the same as the obj
argument; false
otherwise.Object.hashCode()
,
HashMap
public int hashCode()
Object
HashMap
.
The general contract of hashCode
is:
hashCode
method
must consistently return the same integer, provided no information
used in equals
comparisons on the object is modified.
This integer need not remain consistent from one execution of an
application to another execution of the same application.
equals(Object)
method, then calling the hashCode
method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
method, then calling the hashCode
method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hash tables.
As much as is reasonably practical, the hashCode method defined by
class Object
does return distinct integers for distinct
objects. (This is typically implemented by converting the internal
address of the object into an integer, but this implementation
technique is not required by the
JavaTM programming language.)
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)