GridLayout
public
class
GridLayout
extends ViewGroup
java.lang.Object | |||
↳ | android.view.View | ||
↳ | android.view.ViewGroup | ||
↳ | androidx.gridlayout.widget.GridLayout |
A layout that places its children in a rectangular grid.
The grid is composed of a set of infinitely thin lines that separate the
viewing area into cells. Throughout the API, grid lines are referenced
by grid indices. A grid with N
columns
has N + 1
grid indices that run from 0
through N
inclusive. Regardless of how GridLayout is
configured, grid index 0
is fixed to the leading edge of the
container and grid index N
is fixed to its trailing edge
(after padding is taken into account).
Row and Column Specs
Children occupy one or more contiguous cells, as defined by theirrowSpec
and
columnSpec
layout parameters.
Each spec defines the set of rows or columns that are to be
occupied; and how children should be aligned within the resulting group of cells.
Although cells do not normally overlap in a GridLayout, GridLayout does
not prevent children being defined to occupy the same cell or group of cells.
In this case however, there is no guarantee that children will not themselves
overlap after the layout operation completes.
Default Cell Assignment
If a child does not specify the row and column indices of the cell it wishes to occupy, GridLayout assigns cell locations automatically using its:orientation
,
rowCount
and
columnCount
properties.
Space
Space between children may be specified either by using instances of the dedicatedSpace
view or by setting the
leftMargin
,
topMargin
,
rightMargin
and
bottomMargin
layout parameters. When the
useDefaultMargins
property is set, default margins around children are automatically
allocated based on the prevailing UI style guide for the platform.
Each of the margins so defined may be independently overridden by an assignment
to the appropriate layout parameter.
Default values will generally produce a reasonable spacing between components
but values may change between different releases of the platform.
Excess Space Distribution
GridLayout's distribution of excess space accommodates the principle of weight. In the event that no weights are specified, columns and rows are taken as flexible if their views specify some form of alignment within their groups.
The flexibility of a view is therefore influenced by its alignment which is,
in turn, typically defined by setting the
gravity
property of the child's layout parameters.
If either a weight or alignment were defined along a given axis then the component
is taken as flexible in that direction. If no weight or alignment was set,
the component is instead assumed to be inflexible.
Multiple components in the same row or column group are considered to act in parallel. Such a group is flexible only if all of the components within it are flexible. Row and column groups that sit either side of a common boundary are instead considered to act in series. The composite group made of these two elements is flexible if one of its elements is flexible.
To make a column stretch, make sure all of the components inside it define a weight or a gravity. To prevent a column from stretching, ensure that one of the components in the column does not define a weight or a gravity.
When the principle of flexibility does not provide complete disambiguation, GridLayout's algorithms favour rows and columns that are closer to its right and bottom edges. To be more precise, GridLayout treats each of its layout parameters as a constraint in the a set of variables that define the grid-lines along a given axis. During layout, GridLayout solves the constraints so as to return the unique solution to those constraints for which all variables are less-than-or-equal-to the corresponding value in any other valid solution.
Interpretation of GONE
For layout purposes, GridLayout treats views whose visibility status isGONE
, as having zero width and height. This is subtly different from
the policy of ignoring views that are marked as GONE outright. If, for example, a gone-marked
view was alone in a column, that column would itself collapse to zero width if and only if
no gravity was defined on the view. If gravity was defined, then the gone-marked
view has no effect on the layout and the container should be laid out as if the view
had never been added to it. GONE views are taken to have zero weight during excess space
distribution.
These statements apply equally to rows as well as columns, and to groups of rows or columns.
See GridLayout.LayoutParams
for a full description of the
layout parameters used by GridLayout.
Summary
Nested classes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
class |
GridLayout.Alignment
Alignments specify where a view should be placed within a cell group and what size it should be. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
class |
GridLayout.LayoutParams
Layout information associated with each of the children of a GridLayout. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
class |
GridLayout.Spec
A Spec defines the horizontal or vertical characteristics of a group of cells. |
Constants | |
---|---|
int |
ALIGN_BOUNDS
This constant is an |
int |
ALIGN_MARGINS
This constant is an |
int |
HORIZONTAL
The horizontal orientation. |
int |
UNDEFINED
The constant used to indicate that a value is undefined. |
int |
VERTICAL
The vertical orientation. |
Inherited constants | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.view.ViewGroup
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From class
android.view.View
|
Fields | |
---|---|
public
static
final
GridLayout.Alignment |
BASELINE
Indicates that a view should be aligned with the baselines of the other views in its cell group. |
public
static
final
GridLayout.Alignment |
BOTTOM
Indicates that a view should be aligned with the bottom edges of the other views in its cell group. |
public
static
final
GridLayout.Alignment |
CENTER
Indicates that a view should be centered with the other views in its cell group. |
public
static
final
GridLayout.Alignment |
END
Indicates that a view should be aligned with the end edges of the other views in its cell group. |
public
static
final
GridLayout.Alignment |
FILL
Indicates that a view should expanded to fit the boundaries of its cell group. |
public
static
final
GridLayout.Alignment |
LEFT
Indicates that a view should be aligned with the left edges of the other views in its cell group. |
public
static
final
GridLayout.Alignment |
RIGHT
Indicates that a view should be aligned with the right edges of the other views in its cell group. |
public
static
final
GridLayout.Alignment |
START
Indicates that a view should be aligned with the start edges of the other views in its cell group. |
public
static
final
GridLayout.Alignment |
TOP
Indicates that a view should be aligned with the top edges of the other views in its cell group. |
Inherited fields | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.view.View
|
Public constructors | |
---|---|
GridLayout(Context context, AttributeSet attrs, int defStyle)
|
|
GridLayout(Context context, AttributeSet attrs)
|
|
GridLayout(Context context)
|
Public methods | |
---|---|
GridLayout.LayoutParams
|
generateLayoutParams(AttributeSet attrs)
|
int
|
getAlignmentMode()
Returns the alignment mode. |
int
|
getColumnCount()
Returns the current number of columns. |
int
|
getOrientation()
Returns the current orientation. |
Printer
|
getPrinter()
Return the printer that will log diagnostics from this layout. |
int
|
getRowCount()
Returns the current number of rows. |
boolean
|
getUseDefaultMargins()
Returns whether or not this GridLayout will allocate default margins when no corresponding layout parameters are defined. |
boolean
|
isColumnOrderPreserved()
Returns whether or not column boundaries are ordered by their grid indices. |
boolean
|
isRowOrderPreserved()
Returns whether or not row boundaries are ordered by their grid indices. |
void
|
requestLayout()
|
void
|
setAlignmentMode(int alignmentMode)
Sets the alignment mode to be used for all of the alignments between the children of this container. |
void
|
setColumnCount(int columnCount)
ColumnCount is used only to generate default column/column indices when they are not specified by a component's layout parameters. |
void
|
setColumnOrderPreserved(boolean columnOrderPreserved)
When this property is |
void
|
setOrientation(int orientation)
GridLayout uses the orientation property for two purposes:
|
void
|
setPrinter(Printer printer)
Set the printer that will log diagnostics from this layout. |
void
|
setRowCount(int rowCount)
RowCount is used only to generate default row/column indices when they are not specified by a component's layout parameters. |
void
|
setRowOrderPreserved(boolean rowOrderPreserved)
When this property is |
void
|
setUseDefaultMargins(boolean useDefaultMargins)
When |
static
GridLayout.Spec
|
spec(int start, float weight)
Equivalent to: |
static
GridLayout.Spec
|
spec(int start)
Return a Spec,
To leave the start index undefined, use the value |
static
GridLayout.Spec
|
spec(int start, GridLayout.Alignment alignment)
Return a Spec,
To leave the start index undefined, use the value |
static
GridLayout.Spec
|
spec(int start, GridLayout.Alignment alignment, float weight)
Equivalent to: |
static
GridLayout.Spec
|
spec(int start, int size, GridLayout.Alignment alignment)
Equivalent to: |
static
GridLayout.Spec
|
spec(int start, int size, GridLayout.Alignment alignment, float weight)
Return a Spec,
To leave the start index undefined, use the value |
static
GridLayout.Spec
|
spec(int start, int size, float weight)
Equivalent to: |
static
GridLayout.Spec
|
spec(int start, int size)
Return a Spec,
To leave the start index undefined, use the value |
Protected methods | |
---|---|
boolean
|
checkLayoutParams(ViewGroup.LayoutParams p)
|
GridLayout.LayoutParams
|
generateDefaultLayoutParams()
|
GridLayout.LayoutParams
|
generateLayoutParams(ViewGroup.LayoutParams lp)
|
void
|
onLayout(boolean changed, int left, int top, int right, int bottom)
|
void
|
onMeasure(int widthSpec, int heightSpec)
|
Inherited methods | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.view.ViewGroup
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From class
android.view.View
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From class
java.lang.Object
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From interface
android.view.ViewParent
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From interface
android.view.ViewManager
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From interface
android.graphics.drawable.Drawable.Callback
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From interface
android.view.KeyEvent.Callback
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From interface
android.view.accessibility.AccessibilityEventSource
|
Constants
ALIGN_BOUNDS
public static final int ALIGN_BOUNDS
This constant is an alignmentMode
.
When the alignmentMode
is set to ALIGN_BOUNDS
, alignment
is made between the edges of each component's raw
view boundary: i.e. the area delimited by the component's:
top
,
left
,
bottom
and
right
properties.
For example, when GridLayout
is in ALIGN_BOUNDS
mode,
children that belong to a row group that uses TOP
alignment will
all return the same value when their View.getTop()
method is called.
See also:
Constant Value: 0 (0x00000000)
ALIGN_MARGINS
public static final int ALIGN_MARGINS
This constant is an alignmentMode
.
When the alignmentMode
is set to ALIGN_MARGINS
,
the bounds of each view are extended outwards, according
to their margins, before the edges of the resulting rectangle are aligned.
For example, when GridLayout
is in ALIGN_MARGINS
mode,
the quantity top - layoutParams.topMargin
is the same for all children that
belong to a row group that uses TOP
alignment.
See also:
Constant Value: 1 (0x00000001)
HORIZONTAL
public static final int HORIZONTAL
The horizontal orientation.
Constant Value: 0 (0x00000000)
UNDEFINED
public static final int UNDEFINED
The constant used to indicate that a value is undefined.
Fields can use this value to indicate that their values
have not yet been set. Similarly, methods can return this value
to indicate that there is no suitable value that the implementation
can return.
The value used for the constant (currently Integer.MIN_VALUE
) is
intended to avoid confusion between valid values whose sign may not be known.
Constant Value: -2147483648 (0x80000000)
VERTICAL
public static final int VERTICAL
The vertical orientation.
Constant Value: 1 (0x00000001)
Fields
BASELINE
public static final GridLayout.Alignment BASELINE
Indicates that a view should be aligned with the baselines
of the other views in its cell group.
This constant may only be used as an alignment in rowSpecs
.
See also:
BOTTOM
public static final GridLayout.Alignment BOTTOM
Indicates that a view should be aligned with the bottom edges of the other views in its cell group.
CENTER
public static final GridLayout.Alignment CENTER
Indicates that a view should be centered with the other views in its cell group.
This constant may be used in both rowSpecs
and columnSpecs
.
END
public static final GridLayout.Alignment END
Indicates that a view should be aligned with the end edges of the other views in its cell group.
FILL
public static final GridLayout.Alignment FILL
Indicates that a view should expanded to fit the boundaries of its cell group.
This constant may be used in both rowSpecs
and
columnSpecs
.
LEFT
public static final GridLayout.Alignment LEFT
Indicates that a view should be aligned with the left edges of the other views in its cell group.
RIGHT
public static final GridLayout.Alignment RIGHT
Indicates that a view should be aligned with the right edges of the other views in its cell group.
START
public static final GridLayout.Alignment START
Indicates that a view should be aligned with the start edges of the other views in its cell group.
TOP
public static final GridLayout.Alignment TOP
Indicates that a view should be aligned with the top edges of the other views in its cell group.
Public constructors
GridLayout
public GridLayout (Context context, AttributeSet attrs, int defStyle)
Parameters | |
---|---|
context |
Context |
attrs |
AttributeSet |
defStyle |
int |
GridLayout
public GridLayout (Context context, AttributeSet attrs)
Parameters | |
---|---|
context |
Context |
attrs |
AttributeSet |
Public methods
generateLayoutParams
public GridLayout.LayoutParams generateLayoutParams (AttributeSet attrs)
Parameters | |
---|---|
attrs |
AttributeSet |
Returns | |
---|---|
GridLayout.LayoutParams |
getAlignmentMode
public int getAlignmentMode ()
Returns the alignment mode.
Returns | |
---|---|
int |
the alignment mode; either ALIGN_BOUNDS or ALIGN_MARGINS |
getColumnCount
public int getColumnCount ()
Returns the current number of columns. This is either the last value that was set
with setColumnCount(int)
or, if no such value was set, the maximum
value of each the upper bounds defined in GridLayout.LayoutParams.columnSpec
.
Returns | |
---|---|
int |
the current number of columns |
getOrientation
public int getOrientation ()
Returns the current orientation.
Returns | |
---|---|
int |
either HORIZONTAL or VERTICAL |
See also:
getPrinter
public Printer getPrinter ()
Return the printer that will log diagnostics from this layout.
Returns | |
---|---|
Printer |
the printer associated with this view |
See also:
getRowCount
public int getRowCount ()
Returns the current number of rows. This is either the last value that was set
with setRowCount(int)
or, if no such value was set, the maximum
value of each the upper bounds defined in GridLayout.LayoutParams.rowSpec
.
Returns | |
---|---|
int |
the current number of rows |
getUseDefaultMargins
public boolean getUseDefaultMargins ()
Returns whether or not this GridLayout will allocate default margins when no corresponding layout parameters are defined.
Returns | |
---|---|
boolean |
true if default margins should be allocated |
See also:
isColumnOrderPreserved
public boolean isColumnOrderPreserved ()
Returns whether or not column boundaries are ordered by their grid indices.
Returns | |
---|---|
boolean |
true if column boundaries must appear in the order of their indices,
false otherwise |
See also:
isRowOrderPreserved
public boolean isRowOrderPreserved ()
Returns whether or not row boundaries are ordered by their grid indices.
Returns | |
---|---|
boolean |
true if row boundaries must appear in the order of their indices,
false otherwise |
See also:
requestLayout
public void requestLayout ()