java.lang.Object | |||
↳ | android.view.ViewGroup.LayoutParams | ||
↳ | android.view.ViewGroup.MarginLayoutParams | ||
↳ | android.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
setGravity(int)
method.
width
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
.
WRAP_CONTENT
or
MATCH_PARENT
when configuring the children of
a GridLayout.
width
=
WRAP_CONTENT
height
=
WRAP_CONTENT
topMargin
= 0 when
useDefaultMargins
is
false
; otherwise
UNDEFINED
, to
indicate that a default value should be computed on demand.
leftMargin
= 0 when
useDefaultMargins
is
false
; otherwise
UNDEFINED
, to
indicate that a default value should be computed on demand.
bottomMargin
= 0 when
useDefaultMargins
is
false
; otherwise
UNDEFINED
, to
indicate that a default value should be computed on demand.
rightMargin
= 0 when
useDefaultMargins
is
false
; otherwise
UNDEFINED
, to
indicate that a default value should be computed on demand.
rowSpec
.row
=
UNDEFINED
rowSpec
.rowSpan
= 1
rowSpec
.alignment
=
BASELINE
columnSpec
.column
=
UNDEFINED
columnSpec
.columnSpan
= 1
columnSpec
.alignment
=
START
GridLayout
for a more complete description of the conventions
used by GridLayout in the interpretation of the properties of this class.
XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|||||||||
android:layout_column | The column boundary delimiting the left of the group of cells occupied by this view. | ||||||||||
android:layout_columnSpan | The column span: the difference between the right and left boundaries delimiting the group of cells occupied by this view. | ||||||||||
android:layout_gravity | setGravity(int) | Gravity specifies how a component should be placed in its group of cells. | |||||||||
android:layout_row | The row boundary delimiting the top of the group of cells occupied by this view. | ||||||||||
android:layout_rowSpan | The row span: the difference between the bottom and top boundaries delimiting the group of cells occupied by this view. |
[Expand]
Inherited XML Attributes
|
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.view.ViewGroup.MarginLayoutParams
|
|||||||||||
From class
android.view.ViewGroup.LayoutParams
|
[Expand]
Inherited Constants
|
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.view.ViewGroup.LayoutParams
|
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
columnSpec | The spec that defines the horizontal characteristics of the cell group described by these layout parameters. | |||||||||
|
rowSpec | The spec that defines the vertical characteristics of the cell group described by these layout parameters. |
[Expand]
Inherited Fields
|
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.view.ViewGroup.MarginLayoutParams
|
|||||||||||
From class
android.view.ViewGroup.LayoutParams
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Constructs a new LayoutParams instance for this
rowSpec
and
columnSpec
.
|
||||||||||
|
Constructs a new LayoutParams with default values as defined in
GridLayout.LayoutParams
.
|
||||||||||
|
|
||||||||||
|
|
||||||||||
|
Copy constructor.
|
||||||||||
|
Values not defined in the attribute set take the default values
defined in
GridLayout.LayoutParams
.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Compares this instance with the specified object and indicates if they
are equal.
|
||||||||||
|
Returns an integer hash code for this object.
|
||||||||||
|
Describes how the child views are positioned.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Extracts the layout parameters from the supplied attributes.
|
[Expand]
Inherited Methods
|
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.view.ViewGroup.MarginLayoutParams
|
|||||||||||
From class
android.view.ViewGroup.LayoutParams
|
|||||||||||
From class
java.lang.Object
|
The column boundary delimiting the left of the group of cells occupied by this view.
Must be an integer value, such as "
100
".
This may also be a reference to a resource (in the form
"
@[
package
:]
type
:
name
") or
theme attribute (in the form
"
?[
package
:][
type
:]
name
")
containing a value of this type.
This corresponds to the global attribute
resource symbol
layout_column
.
The column span: the difference between the right and left
boundaries delimiting the group of cells occupied by this view.
The default is one.
See
GridLayout.Spec
.
Must be an integer value, such as "
100
".
This may also be a reference to a resource (in the form
"
@[
package
:]
type
:
name
") or
theme attribute (in the form
"
?[
package
:][
type
:]
name
")
containing a value of this type.
This corresponds to the global attribute
resource symbol
layout_columnSpan
.
Gravity specifies how a component should be placed in its group of cells.
The default is LEFT | BASELINE.
See
setGravity(int)
.
Must be one or more (separated by '|') of the following constant values.
Constant | Value | Description |
---|---|---|
top
|
0x30 | Push object to the top of its container, not changing its size. |
bottom
|
0x50 | Push object to the bottom of its container, not changing its size. |
left
|
0x03 | Push object to the left of its container, not changing its size. |
right
|
0x05 | Push object to the right of its container, not changing its size. |
center_vertical
|
0x10 | Place object in the vertical center of its container, not changing its size. |
fill_vertical
|
0x70 | Grow the vertical size of the object if needed so it completely fills its container. |
center_horizontal
|
0x01 | Place object in the horizontal center of its container, not changing its size. |
fill_horizontal
|
0x07 | Grow the horizontal size of the object if needed so it completely fills its container. |
center
|
0x11 | Place the object in the center of its container in both the vertical and horizontal axis, not changing its size. |
fill
|
0x77 | Grow the horizontal and vertical size of the object if needed so it completely fills its container. |
clip_vertical
|
0x80 | Additional option that can be set to have the top and/or bottom edges of the child clipped to its container's bounds. The clip will be based on the vertical gravity: a top gravity will clip the bottom edge, a bottom gravity will clip the top edge, and neither will clip both edges. |
clip_horizontal
|
0x08 | Additional option that can be set to have the left and/or right edges of the child clipped to its container's bounds. The clip will be based on the horizontal gravity: a left gravity will clip the right edge, a right gravity will clip the left edge, and neither will clip both edges. |
start
|
0x00800003 | Push object to the beginning of its container, not changing its size. |
end
|
0x00800005 | Push object to the end of its container, not changing its size. |
This corresponds to the global attribute
resource symbol
layout_gravity
.
The row boundary delimiting the top of the group of cells occupied by this view.
Must be an integer value, such as "
100
".
This may also be a reference to a resource (in the form
"
@[
package
:]
type
:
name
") or
theme attribute (in the form
"
?[
package
:][
type
:]
name
")
containing a value of this type.
This corresponds to the global attribute
resource symbol
layout_row
.
The row span: the difference between the bottom and top
boundaries delimiting the group of cells occupied by this view.
The default is one.
See
GridLayout.Spec
.
Must be an integer value, such as "
100
".
This may also be a reference to a resource (in the form
"
@[
package
:]
type
:
name
") or
theme attribute (in the form
"
?[
package
:][
type
:]
name
")
containing a value of this type.
This corresponds to the global attribute
resource symbol
layout_rowSpan
.
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
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.
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
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.
Constructs a new LayoutParams instance for this
rowSpec
and
columnSpec
. All other fields are initialized with
default values as defined in
GridLayout.LayoutParams
.
rowSpec | the rowSpec |
---|---|
columnSpec | the columnSpec |
Constructs a new LayoutParams with default values as defined in
GridLayout.LayoutParams
.
Copy constructor. Clones the width, height, margin values, row spec, and column spec of the source.
source | The layout params to copy from. |
---|
Values not defined in the attribute set take the default values
defined in
GridLayout.LayoutParams
.
Compares this instance with the specified object and indicates if they
are equal. In order to be equal,
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
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.
o | the object to compare this instance with. |
---|
true
if the specified object is equal to this
Object
;
false
otherwise.
Returns an integer hash code for this object. By contract, any two
objects for which
equals(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.
Describes how the child views are positioned. Default is
LEFT | BASELINE
.
See
Gravity
.
gravity | the new gravity value |
---|
Extracts the layout parameters from the supplied attributes.
attributes | the style attributes to extract the parameters from |
---|---|
widthAttr | the identifier of the width attribute |
heightAttr | the identifier of the height attribute |