Package icyllis.modernui.widget

# Class GridLayout

java.lang.Object
icyllis.modernui.view.View
icyllis.modernui.view.ViewGroup
icyllis.modernui.widget.GridLayout

All Implemented Interfaces:
  `Drawable.Callback`, `ViewManager`, `ViewParent`

public class GridLayout extends ViewGroup
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 their `rowSpec` 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 dedicated

invalid reference

    Space

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, the previous conventions are respected and 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 is `GONE`, 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.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `GridLayout.Alignment`
  Alignments specify where a view should be placed within a cell group and what size it should be.
  `static @interface`
  `GridLayout.AlignmentMode`
  `static class`
  `GridLayout.LayoutParams`
  Layout information associated with each of the children of a GridLayout.
  `static @interface`
  `GridLayout.Orientation`
  `static class`
  `GridLayout.Spec`
  A Spec defines the horizontal or vertical characteristics of a group of cells.

  ## Nested classes/interfaces inherited from class icyllis.modernui.view.ViewGroup

  `ViewGroup.MarginLayoutParams`

  ## Nested classes/interfaces inherited from class icyllis.modernui.view.View

  `View.DragShadow, View.Focusable, View.FocusableMode, View.FocusDirection, View.FocusRealDirection, View.LayoutDir, View.NestedScrollType, View.OnAttachStateChangeListener, View.OnClickListener, View.OnContextClickListener, View.OnCreateContextMenuListener, View.OnDragListener, View.OnFocusChangeListener, View.OnGenericMotionListener, View.OnHoverListener, View.OnKeyListener, View.OnLayoutChangeListener, View.OnLongClickListener, View.OnScrollChangeListener, View.OnTouchListener, View.ResolvedLayoutDir, View.ScrollAxis, View.ScrollBarStyle, View.ScrollIndicators, View.TextAlignment, View.Visibility`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `ALIGN_BOUNDS`
  This constant is an `alignmentMode`.
  `static final int`
  `ALIGN_MARGINS`
  This constant is an `alignmentMode`.
  `static final GridLayout.Alignment`
  `BASELINE`
  Indicates that a view should be aligned with the baselines of the other views in its cell group.
  `static final GridLayout.Alignment`
  `BOTTOM`
  Indicates that a view should be aligned with the bottom edges of the other views in its cell group.
  `static final GridLayout.Alignment`
  `CENTER`
  Indicates that a view should be centered with the other views in its cell group.
  `static final GridLayout.Alignment`
  `END`
  Indicates that a view should be aligned with the end edges of the other views in its cell group.
  `static final GridLayout.Alignment`
  `FILL`
  Indicates that a view should expanded to fit the boundaries of its cell group.
  `static final int`
  `HORIZONTAL`
  The horizontal orientation.
  `static final GridLayout.Alignment`
  `LEFT`
  Indicates that a view should be aligned with the left edges of the other views in its cell group.
  `static final GridLayout.Alignment`
  `RIGHT`
  Indicates that a view should be aligned with the right edges of the other views in its cell group.
  `static final GridLayout.Alignment`
  `START`
  Indicates that a view should be aligned with the start edges of the other views in its cell group.
  `static final GridLayout.Alignment`
  `TOP`
  Indicates that a view should be aligned with the top edges of the other views in its cell group.
  `static final int`
  `UNDEFINED`
  The constant used to indicate that a value is undefined.
  `static final int`
  `VERTICAL`
  The vertical orientation.

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

  `CLIP_TO_PADDING_MASK, FLAG_DISALLOW_INTERCEPT, FOCUS_AFTER_DESCENDANTS, FOCUS_BEFORE_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS`

  ### Fields inherited from class icyllis.modernui.view.View

  `ALPHA, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLE, FOCUSABLE_AUTO, FOCUSABLES_ALL, FOCUSABLES_TOUCH_MODE, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, HAPTIC_FEEDBACK_ENABLED, INVISIBLE, LAYOUT_DIRECTION_INHERIT, LAYOUT_DIRECTION_LOCALE, LAYOUT_DIRECTION_LTR, LAYOUT_DIRECTION_RTL, LAYOUT_DIRECTION_UNDEFINED, MEASURED_HEIGHT_STATE_SHIFT, MEASURED_SIZE_MASK, MEASURED_STATE_MASK, MEASURED_STATE_TOO_SMALL, mPaddingBottom, mPaddingLeft, mPaddingRight, mPaddingTop, mScrollX, mScrollY, NO_ID, NOT_FOCUSABLE, OVER_SCROLL_ALWAYS, OVER_SCROLL_IF_CONTENT_SCROLLS, OVER_SCROLL_NEVER, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, ROTATION, ROTATION_X, ROTATION_Y, SCALE_X, SCALE_Y, SCROLL_AXIS_HORIZONTAL, SCROLL_AXIS_NONE, SCROLL_AXIS_VERTICAL, SCROLL_INDICATOR_BOTTOM, SCROLL_INDICATOR_END, SCROLL_INDICATOR_LEFT, SCROLL_INDICATOR_RIGHT, SCROLL_INDICATOR_START, SCROLL_INDICATOR_TOP, SCROLL_X, SCROLL_Y, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SOUND_EFFECTS_ENABLED, TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_GRAVITY, TEXT_ALIGNMENT_INHERIT, TEXT_ALIGNMENT_TEXT_END, TEXT_ALIGNMENT_TEXT_START, TEXT_ALIGNMENT_VIEW_END, TEXT_ALIGNMENT_VIEW_START, TEXT_DIRECTION_ANY_RTL, TEXT_DIRECTION_FIRST_STRONG, TEXT_DIRECTION_FIRST_STRONG_LTR, TEXT_DIRECTION_FIRST_STRONG_RTL, TEXT_DIRECTION_INHERIT, TEXT_DIRECTION_LOCALE, TEXT_DIRECTION_LTR, TEXT_DIRECTION_RTL, TRANSLATION_X, TRANSLATION_Y, TRANSLATION_Z, TYPE_NON_TOUCH, TYPE_TOUCH, VIEW_MARKER, VISIBLE, WINDOW_FOCUSED_STATE_SET, X, Y, Z`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GridLayout(Context context)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected boolean`
  `checkLayoutParams(ViewGroup.LayoutParams p)`
  Check whether given params fit to this view group.
  `protected GridLayout.LayoutParams`
  `generateDefaultLayoutParams()`
  Returns a set of default layout parameters.
  `protected GridLayout.LayoutParams`
  `generateLayoutParams(ViewGroup.LayoutParams lp)`
  Returns a safe set of layout parameters based on the supplied layout params.
  `int`
  `getAlignmentMode()`
  Returns the alignment mode.
  `int`
  `getColumnCount()`
  Returns the current number of columns.
  `int`
  `getOrientation()`
  Returns the current orientation.
  `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.
  `protected void`
  `onChildVisibilityChanged(View child, int oldVisibility, int newVisibility)`
  We need to call invalidateStructure() when a child's GONE flag changes state.
  `protected void`
  `onLayout(boolean changed, int left, int top, int right, int bottom)`
  Called from `View.layout(int, int, int, int)` when this view should assign a size and position to each of its children.
  `protected void`
  `onMeasure(int widthSpec, int heightSpec)`
  Measure the view and its content to determine the measured width and the measured height.
  `protected void`
  `onSetLayoutParams(View child, ViewGroup.LayoutParams layoutParams)`
  `void`
  `onViewAdded(View child)`
  Called when a new child is added to this ViewGroup.
  `void`
  `onViewRemoved(View child)`
  Called when a child view is removed from this ViewGroup.
  `void`
  `requestLayout()`
  Call this when something has changed which has invalidated the layout of this view.
  `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 `true`, GridLayout is forced to place the column boundaries so that their associated grid indices are in ascending order in the view.
  `void`
  `setOrientation(int orientation)`
  GridLayout uses the orientation property for two purposes: To control the 'direction' in which default row/column indices are generated when they are not specified in a component's layout parameters.
  `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 `true`, GridLayout is forced to place the row boundaries so that their associated grid indices are in ascending order in the view.
  `void`
  `setUseDefaultMargins(boolean useDefaultMargins)`
  When `true`, GridLayout allocates default margins around children based on the child's visual characteristics.
  `static GridLayout.Spec`
  `spec(int start)`
  Return a Spec, `spec`, where: `spec.span = [start, start + 1]`
  `static GridLayout.Spec`
  `spec(int start, float weight)`
  Equivalent to: `spec(start, 1, weight)`.
  `static GridLayout.Spec`
  `spec(int start, int size)`
  Return a Spec, `spec`, where: `spec.span = [start, start + size]`
  `static GridLayout.Spec`
  `spec(int start, int size, float weight)`
  Equivalent to: `spec(start, 1, default_alignment, weight)` - where `default_alignment` is specified in `GridLayout.LayoutParams`.
  `static GridLayout.Spec`
  `spec(int start, int size, GridLayout.Alignment alignment)`
  Equivalent to: `spec(start, size, alignment, 0f)`.
  `static GridLayout.Spec`
  `spec(int start, int size, GridLayout.Alignment alignment, float weight)`
  Return a Spec, `spec`, where: `spec.span = [start, start + size]` `spec.alignment = alignment` `spec.weight = weight`
  `static GridLayout.Spec`
  `spec(int start, GridLayout.Alignment alignment)`
  Return a Spec, `spec`, where: `spec.span = [start, start + 1]` `spec.alignment = alignment`
  `static GridLayout.Spec`
  `spec(int start, GridLayout.Alignment alignment, float weight)`
  Equivalent to: `spec(start, 1, alignment, weight)`.

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

  `addFocusables, addKeyboardNavigationClusters, addStatesFromChildren, addTouchables, addTransientView, addView, addView, addView, addView, addView, addViewInLayout, addViewInLayout, attachViewToParent, bringChildToFront, childDrawableStateChanged, childHasTransientStateChanged, cleanupLayoutState, clearChildFocus, clearDisappearingChildren, clearFocus, detachAllViewsFromParent, detachViewFromParent, detachViewFromParent, detachViewsFromParent, dispatchDraw, dispatchDrawableHotspotChanged, dispatchFinishTemporaryDetach, dispatchGenericPointerEvent, dispatchHoverEvent, dispatchKeyEvent, dispatchKeyShortcutEvent, dispatchSetActivated, dispatchSetPressed, dispatchSetSelected, dispatchStartTemporaryDetach, dispatchTouchEvent, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowVisibilityChanged, drawableStateChanged, drawChild, endViewTransition, findFocus, findViewByPredicateTraversal, findViewTraversal, focusableViewAvailable, focusSearch, getChildAt, getChildCount, getChildDrawingOrder, getChildDrawingOrder, getChildMeasureSpec, getChildVisibleRect, getChildVisibleRect, getClipChildren, getClipToPadding, getDescendantFocusability, getFocusedChild, getLayoutTransition, getNestedScrollAxes, getTouchscreenBlocksFocus, getTransientView, getTransientViewCount, getTransientViewIndex, hasBooleanFlag, hasFocus, hasTransientState, indexOfChild, internalSetPadding, isChildrenDrawingOrderEnabled, isLayoutSuppressed, isTransitionGroup, jumpDrawablesToCurrentState, layout, measureChild, measureChildren, measureChildWithMargins, offsetChildrenTopAndBottom, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onCreateDrawableState, onInterceptHoverEvent, onInterceptTouchEvent, onNestedFling, onNestedPreFling, onNestedPreScroll, onNestedScroll, onNestedScrollAccepted, onRequestFocusInDescendants, onResolvePointerIcon, onStartNestedScroll, onStopNestedScroll, removeAllViews, removeAllViewsInLayout, removeDetachedView, removeTransientView, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, requestChildFocus, requestChildRectangleOnScreen, requestDisallowInterceptTouchEvent, requestFocus, requestTransitionStart, resetResolvedDrawables, resolveDrawables, resolveLayoutDirection, resolveLayoutParams, resolvePadding, resolveRtlPropertiesIfNeeded, resolveTextAlignment, resolveTextDirection, restoreDefaultFocus, setAddStatesFromChildren, setBooleanFlag, setChildrenDrawingOrderEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutTransition, setTouchscreenBlocksFocus, setTransitionGroup, shouldDelayChildPressedState, showContextMenuForChild, startActionModeForChild, startViewTransition, suppressLayout, transformPointToViewLocal, updateViewLayout`

  ### Methods inherited from class icyllis.modernui.view.View

  `addFocusables, addOnAttachStateChangeListener, addOnLayoutChangeListener, awakenScrollBars, awakenScrollBars, callOnClick, cancelLongPress, cancelPendingInputEvents, canReceivePointerEvents, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, combineMeasuredStates, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeScroll, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createContextMenu, dispatchGenericMotionEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPointerEvent, dp, draw, drawableHotspotChanged, findViewById, findViewByPredicate, findViewByPredicateInsideOut, focusSearch, forceHasOverlappingRendering, forceLayout, generateViewId, getAlpha, getAnimationMatrix, getBackground, getBaseline, getBottom, getBoundsOnScreen, getBoundsOnScreen, getContext, getContextMenuInfo, getDefaultSize, getDrawableState, getDrawingRect, getElevation, getFadingEdge, getFadingEdgeLength, getFocusable, getFocusables, getFocusedRect, getForeground, getForegroundGravity, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHasOverlappingRendering, getHeight, getHitRect, getHorizontalScrollbarHeight, getHorizontalScrollbarThumbDrawable, getHorizontalScrollbarTrackDrawable, getId, getInverseMatrix, getKeyDispatcherState, getLayoutDirection, getLayoutParams, getLeft, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextClusterForwardId, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOnLongClickListener, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getPivotX, getPivotY, getRawLayoutDirection, getRawTextAlignment, getRawTextDirection, getRevealOnFocusHint, getRight, getRootView, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollIndicators, getScrollX, getScrollY, getStateListAnimator, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getTag, getTextAlignment, getTextDirection, getTooltipText, getTooltipView, getTop, getTouchables, getTransitionAlpha, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getVerticalFadingEdgeLength, getVerticalScrollbarThumbDrawable, getVerticalScrollbarTrackDrawable, getVerticalScrollbarWidth, getViewRoot, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowVisibility, getX, getY, getZ, handleScrollBarDragging, hasExplicitFocusable, hasFocusable, hasIdentityMatrix, hasNestedScrollingParent, hasOnClickListeners, hasOnLongClickListeners, hasOverlappingRendering, hasTranslationTransientState, hasWindowFocus, invalidate, invalidateDrawable, isActivated, isAttachedToWindow, isClickable, isContextClickable, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isFocusedByDefault, isForegroundInsidePadding, isHapticFeedbackEnabled, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isInLayout, isInScrollingContainer, isInTouchMode, isKeyboardNavigationCluster, isLaidOut, isLayoutDirectionInherited, isLayoutDirectionResolved, isLayoutRequested, isLayoutRtl, isLongClickable, isNestedScrollingEnabled, isPaddingRelative, isPivotSet, isPressed, isRootNamespace, isScrollbarFadingEnabled, isSelected, isShowingLayoutBounds, isShown, isSoundEffectsEnabled, isTemporarilyDetached, isTextAlignmentInherited, isTextAlignmentResolved, isTextDirectionInherited, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVerticalScrollBarHidden, keyboardNavigationClusterSearch, mapRectFromViewToScreenCoords, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onAttachedToWindow, onCancelPendingInputEvents, onCreateContextMenu, onDetachedFromWindow, onDragEvent, onDraw, onDrawForeground, onDrawScrollBars, onFinishTemporaryDetach, onFocusChanged, onGenericMotionEvent, onHoverChanged, onHoverEvent, onKeyDown, onKeyShortcut, onKeyUp, onOverScrolled, onResolveDrawables, onRtlPropertiesChanged, onScrollChanged, onSizeChanged, onStartTemporaryDetach, onTouchEvent, onVisibilityAggregated, onVisibilityChanged, onWindowFocusChanged, onWindowVisibilityChanged, overScrollBy, performButtonActionOnTouchDown, performClick, performContextClick, performContextClick, performHapticFeedback, performHapticFeedback, performLongClick, performLongClick, playSoundEffect, pointInView, post, postDelayed, postInvalidate, postInvalidateDelayed, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, refreshDrawableState, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, requestFocus, requestFocus, requestRectangleOnScreen, requestRectangleOnScreen, requireViewById, resetPivot, resolveSize, resolveSizeAndState, scheduleDrawable, scrollBy, scrollTo, setActivated, setAlpha, setAnimationMatrix, setBackground, setBottom, setClickable, setContextClickable, setDuplicateParentStateEnabled, setElevation, setEnabled, setFocusable, setFocusable, setFocusableInTouchMode, setFocusedByDefault, setFocusedInCluster, setForeground, setForegroundGravity, setFrame, setHapticFeedbackEnabled, setHasTransientState, setHasTranslationTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHorizontalScrollbarThumbDrawable, setHorizontalScrollbarTrackDrawable, setHovered, setId, setIsRootNamespace, setKeyboardNavigationCluster, setLayoutDirection, setLayoutParams, setLeft, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNestedScrollingEnabled, setNextClusterForwardId, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnClickListener, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnScrollChangeListener, setOnTouchListener, setOverScrollMode, setPadding, setPaddingRelative, setPivotX, setPivotY, setPressed, setRevealOnFocusHint, setRight, setRotation, setRotationX, setRotationY, setScaleX, setScaleY, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, setScrollIndicators, setScrollIndicators, setScrollX, setScrollY, setSelected, setSoundEffectsEnabled, setStateListAnimator, setTag, setTextAlignment, setTextDirection, setTooltipText, setTop, setTransitionAlpha, setTransitionName, setTransitionVisibility, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarThumbDrawable, setVerticalScrollbarTrackDrawable, setVisibility, setWillNotDraw, setX, setY, setZ, showContextMenu, showContextMenu, sp, startActionMode, startActionMode, startDragAndDrop, startNestedScroll, stopNestedScroll, toGlobalMotionEvent, toLocalMotionEvent, toString, transformFromViewToWindowSpace, transformMatrixToGlobal, transformMatrixToLocal, unscheduleDrawable, unscheduleDrawable, verifyDrawable, willNotDraw`

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

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface icyllis.modernui.view.ViewParent

  `canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, createContextMenu, getLayoutDirection, getParent, getTextAlignment, getTextDirection, isLayoutDirectionResolved, isLayoutRequested, isTextAlignmentResolved, isTextDirectionResolved, keyboardNavigationClusterSearch`

- ## Field Details

  - ### HORIZONTAL

    public static final int HORIZONTAL
    The horizontal orientation.
    See Also:
      - Constant Field Values

  - ### VERTICAL

    public static final int VERTICAL
    The vertical orientation.
    See Also:
      - Constant Field Values

  - ### 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.
    See Also:
      - Constant Field Values

  - ### 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:
      - `setAlignmentMode(int)`
      - Constant Field Values

  - ### 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:
      - `setAlignmentMode(int)`
      - Constant Field Values

  - ### 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.

  - ### 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.

  - ### 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.

  - ### 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.

  - ### 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.

  - ### 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`.

  - ### 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:
      - `View.getBaseline()`

  - ### 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`.

- ## Constructor Details

  - ### GridLayout

    public GridLayout(Context context)

- ## Method Details

  - ### getOrientation

    public int getOrientation()
    Returns the current orientation.
    Returns:
      either `HORIZONTAL` or `VERTICAL`
    See Also:
      - `setOrientation(int)`

  - ### setOrientation

    public void setOrientation(int orientation)
    GridLayout uses the orientation property for two purposes:
    - To control the 'direction' in which default row/column indices are generated when they are not specified in a component's layout parameters.
    - To control which axis should be processed first during the layout operation: when orientation is `HORIZONTAL` the horizontal axis is laid out first.

    The order in which axes are laid out is important if, for example, the height of one of GridLayout's children is dependent on its width - and its width is, in turn, dependent on the widths of other components.

    If your layout contains a `TextView` (or derivative: `Button`, `EditText`, `CheckBox`, etc.) which is in multi-line mode (the default) it is normally best to leave GridLayout's orientation as `HORIZONTAL` - because `TextView` is capable of deriving its height for a given width, but not the other way around.

    Other than the effects above, orientation does not affect the actual layout operation of GridLayout, so it's fine to leave GridLayout in `HORIZONTAL` mode even if the height of the intended layout greatly exceeds its width.

    The default value of this property is `HORIZONTAL`.

    Parameters:
      `orientation` - either `HORIZONTAL` or `VERTICAL`
    See Also:
      - `getOrientation()`

  - ### 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:
      the current number of rows
    See Also:
      - `setRowCount(int)`
      - `GridLayout.LayoutParams.rowSpec`

  - ### setRowCount

    public 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.
    Parameters:
      `rowCount` - the number of rows
    See Also:
      - `getRowCount()`
      - `GridLayout.LayoutParams.rowSpec`

  - ### 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:
      the current number of columns
    See Also:
      - `setColumnCount(int)`
      - `GridLayout.LayoutParams.columnSpec`

  - ### setColumnCount

    public 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.
    Parameters:
      `columnCount` - the number of columns.
    See Also:
      - `getColumnCount()`
      - `GridLayout.LayoutParams.columnSpec`

  - ### getUseDefaultMargins

    public boolean getUseDefaultMargins()
    Returns whether or not this GridLayout will allocate default margins when no corresponding layout parameters are defined.
    Returns:
      `true` if default margins should be allocated
    See Also:
      - `setUseDefaultMargins(boolean)`

  - ### setUseDefaultMargins

    public void setUseDefaultMargins(boolean useDefaultMargins)
    When `true`, GridLayout allocates default margins around children based on the child's visual characteristics. Each of the margins so defined may be independently overridden by an assignment to the appropriate layout parameter.

    When `false`, the default value of all margins is zero.

    When setting to `true`, consider setting the value of the `alignmentMode` property to `ALIGN_BOUNDS`.

    The default value of this property is `false`.

    Parameters:
      `useDefaultMargins` - use `true` to make GridLayout allocate default margins
    See Also:
      - `getUseDefaultMargins()`
      - `setAlignmentMode(int)`
      - `ViewGroup.MarginLayoutParams.leftMargin`
      - `ViewGroup.MarginLayoutParams.topMargin`
      - `ViewGroup.MarginLayoutParams.rightMargin`
      - `ViewGroup.MarginLayoutParams.bottomMargin`

  - ### getAlignmentMode

    public int getAlignmentMode()
    Returns the alignment mode.
    Returns:
      the alignment mode; either `ALIGN_BOUNDS` or `ALIGN_MARGINS`
    See Also:
      - `ALIGN_BOUNDS`
      - `ALIGN_MARGINS`
      - `setAlignmentMode(int)`

  - ### setAlignmentMode

    public void setAlignmentMode(int alignmentMode)
    Sets the alignment mode to be used for all of the alignments between the children of this container.

    The default value of this property is `ALIGN_MARGINS`.

    Parameters:
      `alignmentMode` - either `ALIGN_BOUNDS` or `ALIGN_MARGINS`
    See Also:
      - `ALIGN_BOUNDS`
      - `ALIGN_MARGINS`
      - `getAlignmentMode()`

  - ### isRowOrderPreserved

    public boolean isRowOrderPreserved()
    Returns whether or not row boundaries are ordered by their grid indices.
    Returns:
      `true` if row boundaries must appear in the order of their indices, `false` otherwise
    See Also:
      - `setRowOrderPreserved(boolean)`

  - ### setRowOrderPreserved

    public void setRowOrderPreserved(boolean rowOrderPreserved)
    When this property is `true`, GridLayout is forced to place the row boundaries so that their associated grid indices are in ascending order in the view.

    When this property is `false` GridLayout is at liberty to place the vertical row boundaries in whatever order best fits the given constraints.

    The default value of this property is `true`.

    Parameters:
      `rowOrderPreserved` - `true` to force GridLayout to respect the order of row boundaries
    See Also:
      - `isRowOrderPreserved()`

  - ### isColumnOrderPreserved

    public boolean isColumnOrderPreserved()
    Returns whether or not column boundaries are ordered by their grid indices.
    Returns:
      `true` if column boundaries must appear in the order of their indices, `false` otherwise
    See Also:
      - `setColumnOrderPreserved(boolean)`

  - ### setColumnOrderPreserved

    public void setColumnOrderPreserved(boolean columnOrderPreserved)
    When this property is `true`, GridLayout is forced to place the column boundaries so that their associated grid indices are in ascending order in the view.

    When this property is `false` GridLayout is at liberty to place the horizontal column boundaries in whatever order best fits the given constraints.

    The default value of this property is `true`.

    Parameters:
      `columnOrderPreserved` - use `true` to force GridLayout to respect the order of column boundaries.
    See Also:
      - `isColumnOrderPreserved()`

  - ### onSetLayoutParams

    @Internal protected void onSetLayoutParams(View child, ViewGroup.LayoutParams layoutParams)
    Overrides:
      `onSetLayoutParams` in class `ViewGroup`

  - ### checkLayoutParams

    protected boolean checkLayoutParams(ViewGroup.LayoutParams p)
    Description copied from class: `ViewGroup`
    Check whether given params fit to this view group.

    See also `ViewGroup.generateLayoutParams(LayoutParams)` See also `ViewGroup.generateDefaultLayoutParams()`

    Overrides:
      `checkLayoutParams` in class `ViewGroup`
    Parameters:
      `p` - layout params to check
    Returns:
      if params matched to this view group

  - ### generateDefaultLayoutParams

    @NonNull protected GridLayout.LayoutParams generateDefaultLayoutParams()
    Description copied from class: `ViewGroup`
    Returns a set of default layout parameters. These parameters are requested when the View passed to `ViewGroup.addView(View)` has no layout parameters already set. If null is returned, an exception is thrown from addView.
    Overrides:
      `generateDefaultLayoutParams` in class `ViewGroup`
    Returns:
      a set of default layout parameters

  - ### generateLayoutParams

    @NonNull protected GridLayout.LayoutParams generateLayoutParams(@NonNull ViewGroup.LayoutParams lp)
    Description copied from class: `ViewGroup`
    Returns a safe set of layout parameters based on the supplied layout params. When a ViewGroup is passed a View whose layout params do not pass the test of `ViewGroup.checkLayoutParams(LayoutParams)`, this method is invoked. This method should return a new set of layout params suitable for this ViewGroup, possibly by copying the appropriate attributes from the specified set of layout params.
    Overrides:
      `generateLayoutParams` in class `ViewGroup`
    Parameters:
      `lp` - The layout parameters to convert into a suitable set of layout parameters for this ViewGroup.
    Returns:
      an instance of `ViewGroup.LayoutParams` or one of its descendants

  - ### onViewAdded

    public void onViewAdded(View child)
    Description copied from class: `ViewGroup`
    Called when a new child is added to this ViewGroup. Overrides should always call super.onViewAdded.
    Overrides:
      `onViewAdded` in class `ViewGroup`
    Parameters:
      `child` - the added child view

  - ### onViewRemoved

    public void onViewRemoved(View child)
    Description copied from class: `ViewGroup`
    Called when a child view is removed from this ViewGroup. Overrides should always call super.onViewRemoved.
    Overrides:
      `onViewRemoved` in class `ViewGroup`
    Parameters:
      `child` - the removed child view

  - ### onChildVisibilityChanged

    @Internal protected void onChildVisibilityChanged(View child, int oldVisibility, int newVisibility)
    We need to call invalidateStructure() when a child's GONE flag changes state. This implementation is a catch-all, invalidating on any change in the visibility flags.
    Overrides:
      `onChildVisibilityChanged` in class `ViewGroup`
    Parameters:
      `child` - The view whose visibility has changed
      `oldVisibility` - The previous visibility value (GONE, INVISIBLE, or VISIBLE).
      `newVisibility` - The new visibility value (GONE, INVISIBLE, or VISIBLE).

  - ### onMeasure

    protected void onMeasure(int widthSpec, int heightSpec)
    Description copied from class: `View`
    Measure the view and its content to determine the measured width and the measured height. This method is invoked by `View.measure(int, int)` and should be overridden by subclasses to provide accurate and efficient measurement of their contents.

    CONTRACT: When overriding this method, you must call `View.setMeasuredDimension(int, int)` to store the measured width and height of this view. Failure to do so will trigger an `IllegalStateException`, thrown by `View.measure(int, int)`. Calling super.onMeasure() is a valid use.

    The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override the base one to provide better measurements of their content.

    Overrides:
      `onMeasure` in class `View`
    Parameters:
      `widthSpec` - width measure specification imposed by the parent `MeasureSpec`
      `heightSpec` - height measure specification imposed by the parent `MeasureSpec`

  - ### requestLayout

    public void requestLayout()
    Description copied from class: `View`
    Call this when something has changed which has invalidated the layout of this view. This will schedule a layout pass of the view tree. This should not be called while the view hierarchy is currently in a layout pass (`View.isInLayout()`. If layout is happening, the request may be honored at the end of the current layout pass (and then layout will run again) or after the current frame is drawn and the next layout occurs.

    Subclasses which override this method should call the superclass method to handle possible request-during-layout errors correctly.

    Specified by:
      `requestLayout` in interface `ViewParent`
    Overrides:
      `requestLayout` in class `View`

  - ### onLayout

    protected void onLayout(boolean changed, int left, int top, int right, int bottom)
    Called from `View.layout(int, int, int, int)` when this view should assign a size and position to each of its children.

    Derived classes with children should override this method and call layout on each of their children.

    Specified by:
      `onLayout` in class `ViewGroup`
    Parameters:
      `changed` - This is a new size or position for this view
      `left` - Left position, relative to parent
      `top` - Top position, relative to parent
      `right` - Right position, relative to parent
      `bottom` - Bottom position, relative to parent

  - ### spec

    public static GridLayout.Spec spec(int start, int size, GridLayout.Alignment alignment, float weight)
    Return a Spec, `spec`, where:
    - `spec.span = [start, start + size]`
    - `spec.alignment = alignment`
    - `spec.weight = weight`

    To leave the start index undefined, use the value `UNDEFINED`.

    Parameters:
      `start` - the start
      `size` - the size
      `alignment` - the alignment
      `weight` - the weight

  - ### spec

    public static GridLayout.Spec spec(int start, GridLayout.Alignment alignment, float weight)
    Equivalent to: `spec(start, 1, alignment, weight)`.
    Parameters:
      `start` - the start
      `alignment` - the alignment
      `weight` - the weight

  - ### spec

    public static GridLayout.Spec spec(int start, int size, float weight)
    Equivalent to: `spec(start, 1, default_alignment, weight)` - where `default_alignment` is specified in `GridLayout.LayoutParams`.
    Parameters:
      `start` - the start
      `size` - the size
      `weight` - the weight

  - ### spec

    public static GridLayout.Spec spec(int start, float weight)
    Equivalent to: `spec(start, 1, weight)`.
    Parameters:
      `start` - the start
      `weight` - the weight

  - ### spec

    public static GridLayout.Spec spec(int start, int size, GridLayout.Alignment alignment)
    Equivalent to: `spec(start, size, alignment, 0f)`.
    Parameters:
      `start` - the start
      `size` - the size
      `alignment` - the alignment

  - ### spec

    public static GridLayout.Spec spec(int start, GridLayout.Alignment alignment)
    Return a Spec, `spec`, where:
    - `spec.span = [start, start + 1]`
    - `spec.alignment = alignment`

    To leave the start index undefined, use the value `UNDEFINED`.

    Parameters:
      `start` - the start index
      `alignment` - the alignment
    See Also:
      - `spec(int, int, Alignment)`

  - ### spec

    public static GridLayout.Spec spec(int start, int size)
    Return a Spec, `spec`, where:
    - `spec.span = [start, start + size]`

    To leave the start index undefined, use the value `UNDEFINED`.

    Parameters:
      `start` - the start
      `size` - the size
    See Also:
      - `spec(int, Alignment)`

  - ### spec

    public static GridLayout.Spec spec(int start)
    Return a Spec, `spec`, where:
    - `spec.span = [start, start + 1]`

    To leave the start index undefined, use the value `UNDEFINED`.

    Parameters:
      `start` - the start index
    See Also:
      - `spec(int, int)`