GridLayout


class GridLayout : 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 android.widget.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, 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.

name android:orientation

name android:rowCount

name android:columnCount

name android:useDefaultMargins

name android:rowOrderPreserved

name android:columnOrderPreserved

Summary

Nested types

abstract class GridLayout.Alignment

Alignments specify where a view should be placed within a cell group and what size it should be.

Layout information associated with each of the children of a GridLayout.

A Spec defines the horizontal or vertical characteristics of a group of cells.

Constants

const Int

This constant is an alignmentMode.

const Int

This constant is an alignmentMode.

const GridLayout.Alignment!

Indicates that a view should be aligned with the baselines of the other views in its cell group.

const GridLayout.Alignment!

Indicates that a view should be aligned with the bottom edges of the other views in its cell group.

const GridLayout.Alignment!

Indicates that a view should be centered with the other views in its cell group.

const GridLayout.Alignment!

Indicates that a view should be aligned with the end edges of the other views in its cell group.

const GridLayout.Alignment!

Indicates that a view should expanded to fit the boundaries of its cell group.

const Int

The horizontal orientation.

const GridLayout.Alignment!

Indicates that a view should be aligned with the left edges of the other views in its cell group.

const GridLayout.Alignment!

Indicates that a view should be aligned with the right edges of the other views in its cell group.

const GridLayout.Alignment!

Indicates that a view should be aligned with the start edges of the other views in its cell group.

const GridLayout.Alignment!

Indicates that a view should be aligned with the top edges of the other views in its cell group.

const Int
UNDEFINED = -2147483648

The constant used to indicate that a value is undefined.

const Int

The vertical orientation.

Public constructors

GridLayout(context: Context!)
GridLayout(context: Context!, attrs: AttributeSet!)
GridLayout(context: Context!, attrs: AttributeSet!, defStyle: Int)

Public functions

GridLayout.LayoutParams!
Int

Returns the alignment mode.

Int

Returns the current number of columns.

Int

Returns the current orientation.

Printer!

Return the printer that will log diagnostics from this layout.

Int

Returns the current number of rows.

Boolean

Returns whether or not this GridLayout will allocate default margins when no corresponding layout parameters are defined.

Boolean

Returns whether or not column boundaries are ordered by their grid indices.

Boolean

Returns whether or not row boundaries are ordered by their grid indices.

Unit
Unit
setAlignmentMode(alignmentMode: Int)

Sets the alignment mode to be used for all of the alignments between the children of this container.

Unit
setColumnCount(columnCount: Int)

ColumnCount is used only to generate default column/column indices when they are not specified by a component's layout parameters.

Unit
setColumnOrderPreserved(columnOrderPreserved: Boolean)

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.

Unit
setOrientation(orientation: Int)

GridLayout uses the orientation property for two purposes:

Unit
setPrinter(printer: Printer!)

Set the printer that will log diagnostics from this layout.

Unit
setRowCount(rowCount: Int)

RowCount is used only to generate default row/column indices when they are not specified by a component's layout parameters.

Unit
setRowOrderPreserved(rowOrderPreserved: Boolean)

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.

Unit
setUseDefaultMargins(useDefaultMargins: Boolean)

When true, GridLayout allocates default margins around children based on the child's visual characteristics.

java-static GridLayout.Spec!
spec(start: Int)

Return a Spec, spec, where:

java-static GridLayout.Spec!
spec(start: Int, alignment: GridLayout.Alignment!)

Return a Spec, spec, where:

java-static GridLayout.Spec!
spec(start: Int, size: Int)

Return a Spec, spec, where:

java-static GridLayout.Spec!
spec(start: Int, weight: Float)

Equivalent to: spec(start, 1, weight).

java-static GridLayout.Spec!
spec(start: Int, alignment: GridLayout.Alignment!, weight: Float)

Equivalent to: spec(start, 1, alignment, weight).

java-static GridLayout.Spec!
spec(start: Int, size: Int, alignment: GridLayout.Alignment!)

Equivalent to: spec(start, size, alignment, 0f).

java-static GridLayout.Spec!
spec(start: Int, size: Int, weight: Float)

Equivalent to: spec(start, 1, default_alignment, weight) - where default_alignment is specified in android.widget.GridLayout.LayoutParams.

java-static GridLayout.Spec!
spec(start: Int, size: Int, alignment: GridLayout.Alignment!, weight: Float)

Return a Spec, spec, where:

Inherited Constants

From android.view.View
const Int
const Int
const Int
const Int
const Int
const Int
const Property<View!, Float!>!
const Int
const String!
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE = "creditCardExpirationDate"
const String!
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY = "creditCardExpirationDay"
const String!
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH = "creditCardExpirationMonth"
const String!
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR = "creditCardExpirationYear"
const String!
const String!
AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE = "creditCardSecurityCode"
const String!
const String!
const String!
const String!
const String!
const String!
const String!
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const Int
const Int
const Int
const Int
const Int
const Int
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const Int
const Int
const Int
const Int
const Int
const Int
const Int
GONE = 8
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
KEEP_SCREEN_ON = 67108864
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
NO_ID = -1
const Int
const Int
const Int
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const Property<View!, Float!>!
const Property<View!, Float!>!
const Property<View!, Float!>!
const Property<View!, Float!>!
const Property<View!, Float!>!
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const IntArray<Int>!
const IntArray<Int>!
const Int
const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Property<View!, Float!>!
const Property<View!, Float!>!
const Property<View!, Float!>!
const String!
VIEW_LOG_TAG = "View"
const Int
const IntArray<Int>!
const Property<View!, Float!>!
const Property<View!, Float!>!
const Property<View!, Float!>!
From android.view.ViewGroup
const Int
const Int
const Int
const Int
const Int
const Int
const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

Inherited functions

From android.view.View
Unit
Unit
Unit
ViewPropertyAnimator!
Unit
Unit
Boolean
Unit
Unit

This function is deprecated.

Unit
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Unit
Unit
Unit
Boolean
Unit
Unit
java-static Int
combineMeasuredStates(curState: Int, newState: Int)
Int
Int
Int
Unit
WindowInsets!
computeSystemWindowInsets(in: WindowInsets!, outLocalInsets: Rect!)
Int
Int
Int
AccessibilityNodeInfo!
Unit
Unit

This function is deprecated.

Boolean
Boolean
dispatchNestedFling(velocityX: Float, velocityY: Float, consumed: Boolean)
Boolean
dispatchNestedPreFling(velocityX: Float, velocityY: Float)
Boolean
dispatchNestedPrePerformAccessibilityAction(
    action: Int,
    arguments: Bundle!
)
Boolean
dispatchNestedPreScroll(
    dx: Int,
    dy: Int,
    consumed: IntArray!,
    offsetInWindow: IntArray!
)
Boolean
dispatchNestedScroll(
    dxConsumed: Int,
    dyConsumed: Int,
    dxUnconsumed: Int,
    dyUnconsumed: Int,
    offsetInWindow: IntArray!
)
Boolean
Unit
draw(canvas: Canvas!)
Unit
OnBackInvokedDispatcher!
T!
<T : View?> findViewById(id: Int)
T!
<T : View?> findViewWithTag(tag: Any!)
Boolean

This function is deprecated.

Unit
forceHasOverlappingRendering(hasOverlappingRendering: Boolean)
Unit
Unit
generateDisplayHash(
    hashAlgorithm: String!,
    bounds: Rect!,
    executor: Executor!,
    callback: DisplayHashResultCallback!
)
java-static Int
View.AccessibilityDelegate!
Int
AccessibilityNodeProvider!
CharSequence!
Int
Int
String!
String!
Float
Animation!
Matrix!
IBinder!
IntArray<Int>!
(Mutable)Map<Int!, Int!>!
Array<String!>!
AutofillId!
Int
AutofillValue!
Drawable!
BlendMode!
ColorStateList!
PorterDuff.Mode!
Int
Int
Float
Int
Float
Rect!
Boolean
getClipBounds(outRect: Rect!)
Boolean
ContentCaptureSession!
CharSequence!
Context!
ContextMenu.ContextMenuInfo!
Boolean
java-static Int
getDefaultSize(size: Int, measureSpec: Int)
Display!
IntArray<Int>!
Bitmap!

This function is deprecated.

Int

This function is deprecated.

Int

This function is deprecated.

Unit
getDrawingRect(outRect: Rect!)
Long
Float
Int
Boolean
Boolean
Int
ArrayList<View!>!
getFocusables(direction: Int)
Unit
Drawable!
Int
BlendMode!
ColorStateList!
PorterDuff.Mode!
Boolean
getGlobalVisibleRect(r: Rect!, globalOffset: Point!)
Handler!
Float
Float
Float
Float
Runnable!
Boolean
Int
Unit
getHitRect(outRect: Rect!)
Int
Int
Drawable!
Drawable!
Int
Int
Int
Int
Boolean
KeyEvent.DispatcherState!
Int
Int
Int
ViewGroup.LayoutParams!
Int
Float
Int
Boolean
Unit
Unit
Unit
Matrix!
Int
Int
Int
Int
Int
Int
Int
Int
Int
Int
Int
Int
Int
View.OnFocusChangeListener!
Int
ViewOutlineProvider!
Int
Int
ViewOverlay!
Int
Int
Int
Int
Int
Int
ViewParent!
ViewParent!
Float
Float
PointerIcon!
(Mutable)List<Rect!>!
Array<String!>!
Resources!
Boolean
Int
Float
Int
AttachedSurfaceControl!
View!
WindowInsets!
Float
Float
Float
Float
Float
Int
Int
Int
Int
Int
Int
Int
Int
Int
Int
CharSequence!
StateListAnimator!
Int
Int
(Mutable)List<Rect!>!
Int

This function is deprecated.

Any!
Int
Int
CharSequence!
Int
Float
Int
TouchDelegate!
ArrayList<View!>!
Float
String!
Float
Float
Float
Long
Int
Int
Drawable!
Drawable!
Int
ViewTranslationResponse!
ViewTreeObserver!
Int
Int
Int
WindowId!
WindowInsetsController!
Int

This function is deprecated.

IBinder!
Int
Unit
Float
Float
Float
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
java-static View!
inflate(context: Context!, resource: Int, root: ViewGroup!)
Unit
invalidate(dirty: Rect!)

This function is deprecated.

Unit
Unit
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean

This function is deprecated.

Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
View!
keyboardNavigationClusterSearch(currentCluster: View!, direction: Int)
Unit
measure(widthMeasureSpec: Int, heightMeasureSpec: Int)
java-static IntArray<Int>!
mergeDrawableStates(baseState: IntArray!, additionalState: IntArray!)
Unit
Unit
Unit
Unit
WindowInsets!
Unit
Boolean
Boolean
Unit
Unit
InputConnection!
Unit
onCreateViewTranslationRequest(
    supportedFormats: IntArray!,
    requestsCollector: Consumer<ViewTranslationRequest!>!
)
Unit
onCreateVirtualViewTranslationRequests(
    virtualIds: LongArray!,
    supportedFormats: IntArray!,
    requestsCollector: Consumer<ViewTranslationRequest!>!
)
Unit
Boolean
Unit
onDraw(canvas: Canvas!)
Unit
Unit
Boolean
Unit
Unit
Unit
onFocusChanged(
    gainFocus: Boolean,
    direction: Int,
    previouslyFocusedRect: Rect!
)
Boolean
Unit
Boolean
Unit
Unit
Boolean
onKeyDown(keyCode: Int, event: KeyEvent!)
Boolean
onKeyLongPress(keyCode: Int, event: KeyEvent!)
Boolean
onKeyMultiple(keyCode: Int, repeatCount: Int, event: KeyEvent!)
Boolean
onKeyPreIme(keyCode: Int, event: KeyEvent!)
Boolean
onKeyShortcut(keyCode: Int, event: KeyEvent!)
Boolean
onKeyUp(keyCode: Int, event: KeyEvent!)
Unit
onOverScrolled(
    scrollX: Int,
    scrollY: Int,
    clampedX: Boolean,
    clampedY: Boolean
)
Unit
Unit
Unit
Unit
Unit
Unit
Unit
ContentInfo!
Unit
Unit
onRtlPropertiesChanged(layoutDirection: Int)
Parcelable!
Unit
onScreenStateChanged(screenState: Int)
Unit
onScrollCaptureSearch(
    localVisibleRect: Rect!,
    windowOffset: Point!,
    targets: Consumer<ScrollCaptureTarget!>!
)
Unit
onScrollChanged(l: Int, t: Int, oldl: Int, oldt: Int)
Boolean
onSetAlpha(alpha: Int)
Unit
onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int)
Unit
Boolean
Boolean
Unit
Unit
Unit
Unit
onVisibilityChanged(changedView: View!, visibility: Int)
Unit
onWindowFocusChanged(hasWindowFocus: Boolean)
Unit

This function is deprecated.

Unit
Boolean
overScrollBy(
    deltaX: Int,
    deltaY: Int,
    scrollX: Int,
    scrollY: Int,
    scrollRangeX: Int,
    scrollRangeY: Int,
    maxOverScrollX: Int,
    maxOverScrollY: Int,
    isTouchEvent: Boolean
)
Boolean
performAccessibilityAction(action: Int, arguments: Bundle!)
Boolean
Boolean
Boolean
performHapticFeedback(feedbackConstant: Int)
Boolean
ContentInfo!
Unit
playSoundEffect(soundConstant: Int)
Boolean
post(action: Runnable!)
Boolean
postDelayed(action: Runnable!, delayMillis: Long)
Unit
Unit
postInvalidateDelayed(delayMilliseconds: Long)
Unit
Unit
Unit
postOnAnimationDelayed(action: Runnable!, delayMillis: Long)
Unit
Unit
Boolean
Unit
Unit
Unit
Unit
Unit

This function is deprecated.

Boolean
Unit
Boolean
Unit
T!
<T : View?> requireViewById(id: Int)
Unit
java-static Int
resolveSize(size: Int, measureSpec: Int)
java-static Int
resolveSizeAndState(size: Int, measureSpec: Int, childMeasuredState: Int)
Unit
Unit
saveAttributeDataForStyleable(
    context: Context!,
    styleable: IntArray!,
    attrs: AttributeSet!,
    t: TypedArray!,
    defStyleAttr: Int,
    defStyleRes: Int
)
Unit
Unit
scheduleDrawable(who: Drawable!, what: Runnable!, when: Long)
Unit
scrollBy(x: Int, y: Int)
Unit
scrollTo(x: Int, y: Int)
Unit
Unit
Unit
setAccessibilityDataSensitive(accessibilityDataSensitive: Int)
Unit
Unit
Unit
Unit
setAccessibilityPaneTitle(accessibilityPaneTitle: CharSequence!)
Unit
Unit
Unit
setActivated(activated: Boolean)
Unit
setAllowClickWhenDisabled(clickableWhenDisabled: Boolean)
Unit
Unit
Unit
setAlpha(alpha: Float)
Unit
setAnimation(animation: Animation!)
Unit
Unit
Unit
setAutofillHints(autofillHints: Array<String!>!)
Unit
Unit
setBackground(background: Drawable!)
Unit
Unit

This function is deprecated.

Unit
Unit
Unit
Unit
Unit
setBottom(bottom: Int)
Unit
Unit
setClickable(clickable: Boolean)
Unit
setClipBounds(clipBounds: Rect!)
Unit
setClipToOutline(clipToOutline: Boolean)
Unit
Unit
setContentDescription(contentDescription: CharSequence!)
Unit
setContextClickable(contextClickable: Boolean)
Unit
setDefaultFocusHighlightEnabled(defaultFocusHighlightEnabled: Boolean)
Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit
Unit
setElevation(elevation: Float)
Unit
setEnabled(enabled: Boolean)
Unit
Unit
Unit
setFitsSystemWindows(fitSystemWindows: Boolean)
Unit
setFocusable(focusable: Boolean)
Unit
setFocusableInTouchMode(focusableInTouchMode: Boolean)
Unit
setFocusedByDefault(isFocusedByDefault: Boolean)
Unit
Unit
setForeground(foreground: Drawable!)
Unit
Unit
Unit
Unit
Unit
setHandwritingBoundsOffsets(
    offsetLeft: Float,
    offsetTop: Float,
    offsetRight: Float,
    offsetBottom: Float
)
Unit
Unit
setHapticFeedbackEnabled(hapticFeedbackEnabled: Boolean)
Unit
setHasTransientState(hasTransientState: Boolean)
Unit
setHorizontalFadingEdgeEnabled(horizontalFadingEdgeEnabled: Boolean)
Unit
setHorizontalScrollBarEnabled(horizontalScrollBarEnabled: Boolean)
Unit
Unit
Unit
setHovered(hovered: Boolean)
Unit
setId(id: Int)
Unit
Unit
Unit
Unit
setIsCredential(isCredential: Boolean)
Unit
setIsHandwritingDelegate(isHandwritingDelegate: Boolean)
Unit
setKeepScreenOn(keepScreenOn: Boolean)
Unit
Unit
Unit
Unit
setLayerType(layerType: Int, paint: Paint!)
Unit
setLayoutDirection(layoutDirection: Int)
Unit
Unit
setLeft(left: Int)
Unit
setLeftTopRightBottom(left: Int, top: Int, right: Int, bottom: Int)
Unit
setLongClickable(longClickable: Boolean)
Unit
setMeasuredDimension(measuredWidth: Int, measuredHeight: Int)
Unit
setMinimumHeight(minHeight: Int)
Unit
setMinimumWidth(minWidth: Int)
Unit
Unit
setNextClusterForwardId(nextClusterForwardId: Int)
Unit
setNextFocusDownId(nextFocusDownId: Int)
Unit
setNextFocusForwardId(nextFocusForwardId: Int)
Unit
setNextFocusLeftId(nextFocusLeftId: Int)
Unit
setNextFocusRightId(nextFocusRightId: Int)
Unit
setNextFocusUpId(nextFocusUpId: Int)
Unit
Unit
Unit
Unit
Unit
Unit
Unit
Unit
Unit
Unit
Unit
Unit
setOnReceiveContentListener(
    mimeTypes: Array<String!>!,
    listener: OnReceiveContentListener!
)
Unit
Unit

This function is deprecated.

Unit
Unit
Unit
Unit
Unit
setOverScrollMode(overScrollMode: Int)
Unit
setPadding(left: Int, top: Int, right: Int, bottom: Int)
Unit
setPaddingRelative(start: Int, top: Int, end: Int, bottom: Int)
Unit
setPivotX(pivotX: Float)
Unit
setPivotY(pivotY: Float)
Unit
setPointerIcon(pointerIcon: PointerIcon!)
Unit
setPreferKeepClear(preferKeepClear: Boolean)
Unit
Unit
setPressed(pressed: Boolean)
Unit
setRenderEffect(renderEffect: RenderEffect!)
Unit
setRevealOnFocusHint(revealOnFocus: Boolean)
Unit
setRight(right: Int)
Unit
setRotation(rotation: Float)
Unit
setRotationX(rotationX: Float)
Unit
setRotationY(rotationY: Float)
Unit
Unit
Unit
setScaleX(scaleX: Float)
Unit
setScaleY(scaleY: Float)
Unit
setScreenReaderFocusable(screenReaderFocusable: Boolean)
Unit
setScrollBarDefaultDelayBeforeFade(
    scrollBarDefaultDelayBeforeFade: Int
)
Unit
setScrollBarFadeDuration(scrollBarFadeDuration: Int)
Unit
setScrollBarSize(scrollBarSize: Int)
Unit
Unit
Unit
Unit
setScrollContainer(isScrollContainer: Boolean)
Unit
setScrollIndicators(indicators: Int)
Unit
setScrollX(value: Int)
Unit
setScrollY(value: Int)
Unit
Unit
setSelected(selected: Boolean)
Unit
setSoundEffectsEnabled(soundEffectsEnabled: Boolean)
Unit
setStateDescription(stateDescription: CharSequence!)
Unit
Unit
Unit

This function is deprecated.

Unit
setTag(tag: Any!)
Unit
setTextAlignment(textAlignment: Int)
Unit
setTextDirection(textDirection: Int)
Unit
Unit
setTop(top: Int)
Unit
Unit
Unit
setTransitionName(transitionName: String!)
Unit
Unit
setTranslationX(translationX: Float)
Unit
setTranslationY(translationY: Float)
Unit
setTranslationZ(translationZ: Float)
Unit
setVerticalFadingEdgeEnabled(verticalFadingEdgeEnabled: Boolean)
Unit
setVerticalScrollBarEnabled(verticalScrollBarEnabled: Boolean)
Unit
Unit
Unit
Unit
Unit
setVisibility(visibility: Int)
Unit
setWillNotCacheDrawing(willNotCacheDrawing: Boolean)

This function is deprecated.

Unit
setWillNotDraw(willNotDraw: Boolean)
Unit
setX(x: Float)
Unit
setY(y: Float)
Unit
setZ(z: Float)
Boolean
ActionMode!
Unit
Boolean
startDrag(
    data: ClipData!,
    shadowBuilder: View.DragShadowBuilder!,
    myLocalState: Any!,
    flags: Int
)

This function is deprecated.

Boolean
startDragAndDrop(
    data: ClipData!,
    shadowBuilder: View.DragShadowBuilder!,
    myLocalState: Any!,
    flags: Int
)
Boolean
Unit
String!
Unit
Unit
Unit
Unit
Boolean
Boolean

This function is deprecated.

Boolean
From android.view.ViewGroup
Unit
Unit
addExtraDataToAccessibilityNodeInfo(
    info: AccessibilityNodeInfo!,
    extraDataKey: String!,
    arguments: Bundle!
)
Unit
addFocusables(views: ArrayList<View!>!, direction: Int, focusableMode: Int)
Unit
addKeyboardNavigationClusters(
    views: (Mutable)Collection<View!>!,
    direction: Int
)
Boolean
Unit
Unit
addView(child: View!)
Boolean
addViewInLayout(child: View!, index: Int, params: ViewGroup.LayoutParams!)
Unit
attachLayoutAnimationParameters(
    child: View!,
    params: ViewGroup.LayoutParams!,
    index: Int,
    count: Int
)
Unit
attachViewToParent(child: View!, index: Int, params: ViewGroup.LayoutParams!)
Unit
Boolean
Unit
Unit
childHasTransientStateChanged(
    child: View!,
    childHasTransientState: Boolean
)
Unit
Unit
Unit
Unit
Unit
debug(depth: Int)
Unit
Unit
Unit
detachViewsFromParent(start: Int, count: Int)
WindowInsets!
Boolean
Unit
Unit
dispatchCreateViewTranslationRequest(
    viewIds: (Mutable)Map<AutofillId!, LongArray!>!,
    supportedFormats: IntArray!,
    capability: TranslationCapability!,
    requests: (Mutable)List<ViewTranslationRequest!>!
)
Unit
Boolean
Unit
dispatchDraw(canvas: Canvas!)
Unit
Unit
Unit
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Unit
Unit
Unit
Unit
Unit
Unit
dispatchScrollCaptureSearch(
    localVisibleRect: Rect!,
    windowOffset: Point!,
    targets: Consumer<ScrollCaptureTarget!>!
)
Unit
Unit
Unit
Unit
Unit

This function is deprecated.

Unit
Boolean
Boolean
Boolean
dispatchUnhandledMove(focused: View!, direction: Int)
Unit
dispatchVisibilityChanged(changedView: View!, visibility: Int)
Unit
Unit
Unit
WindowInsets!
dispatchWindowInsetsAnimationProgress(
    insets: WindowInsets!,
    runningAnimations: (Mutable)List<WindowInsetsAnimation!>!
)
WindowInsetsAnimation.Bounds!
Unit

This function is deprecated.

Unit
Boolean
drawChild(canvas: Canvas!, child: View!, drawingTime: Long)
Unit
Unit
View!
OnBackInvokedDispatcher!
Unit
findViewsWithText(
    outViews: ArrayList<View!>!,
    text: CharSequence!,
    flags: Int
)
View!
focusSearch(focused: View!, direction: Int)
Unit
Boolean
CharSequence!
View!
getChildAt(index: Int)
Int
Int
getChildDrawingOrder(childCount: Int, drawingPosition: Int)
java-static Int
getChildMeasureSpec(spec: Int, padding: Int, childDimension: Int)
Boolean
Boolean
getChildVisibleRect(child: View!, r: Rect!, offset: Point!)
Boolean
Boolean
Int
View!
LayoutAnimationController!
Animation.AnimationListener!
Int
LayoutTransition!
Int
ViewGroupOverlay!
Int

This function is deprecated.

Boolean
Boolean
Boolean
Int
indexOfChild(child: View!)
Unit
invalidateChild(child: View!, dirty: Rect!)

This function is deprecated.

ViewParent!
invalidateChildInParent(location: IntArray!, dirty: Rect!)

This function is deprecated.

Boolean

This function is deprecated.

Boolean

This function is deprecated.

Boolean
Boolean

This function is deprecated.

Boolean
Boolean
Boolean
Unit
Unit
layout(l: Int, t: Int, r: Int, b: Int)
Unit
measureChild(
    child: View!,
    parentWidthMeasureSpec: Int,
    parentHeightMeasureSpec: Int
)
Unit
measureChildWithMargins(
    child: View!,
    parentWidthMeasureSpec: Int,
    widthUsed: Int,
    parentHeightMeasureSpec: Int,
    heightUsed: Int
)
Unit
measureChildren(widthMeasureSpec: Int, heightMeasureSpec: Int)
Unit
notifySubtreeAccessibilityStateChanged(
    child: View!,
    source: View!,
    changeType: Int
)
Unit
offsetDescendantRectToMyCoords(descendant: View!, rect: Rect!)
Unit
offsetRectIntoDescendantCoords(descendant: View!, rect: Rect!)
Unit
IntArray<Int>!
Unit
onDescendantInvalidated(child: View!, target: View!)
Unit
Boolean
Boolean
Boolean
onNestedFling(
    target: View!,
    velocityX: Float,
    velocityY: Float,
    consumed: Boolean
)
Boolean
onNestedPreFling(target: View!, velocityX: Float, velocityY: Float)
Boolean
onNestedPrePerformAccessibilityAction(
    target: View!,
    action: Int,
    args: Bundle!
)
Unit
onNestedPreScroll(target: View!, dx: Int, dy: Int, consumed: IntArray!)
Unit
onNestedScroll(
    target: View!,
    dxConsumed: Int,
    dyConsumed: Int,
    dxUnconsumed: Int,
    dyUnconsumed: Int
)
Unit
onNestedScrollAccepted(child: View!, target: View!, axes: Int)
Boolean
onRequestFocusInDescendants(direction: Int, previouslyFocusedRect: Rect!)
Boolean
PointerIcon!
onResolvePointerIcon(event: MotionEvent!, pointerIndex: Int)
Boolean
onStartNestedScroll(child: View!, target: View!, nestedScrollAxes: Int)
Unit
Unit
onViewAdded(child: View!)
Unit
Unit
Unit
Unit
Unit
removeDetachedView(child: View!, animate: Boolean)
Unit
removeView(view: View!)
Unit
removeViewAt(index: Int)
Unit
Unit
removeViews(start: Int, count: Int)
Unit
removeViewsInLayout(start: Int, count: Int)
Unit
requestChildFocus(child: View!, focused: View!)
Boolean
requestChildRectangleOnScreen(
    child: View!,
    rectangle: Rect!,
    immediate: Boolean
)
Unit
Boolean
requestFocus(direction: Int, previouslyFocusedRect: Rect!)
Boolean
Unit
Boolean
Unit
Unit
Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit
Unit

This function is deprecated.

Unit
setClipChildren(clipChildren: Boolean)
Unit
setClipToPadding(clipToPadding: Boolean)
Unit
Unit
Unit
Unit
setLayoutMode(layoutMode: Int)
Unit
Unit
Unit
Unit
setPersistentDrawingCache(drawingCacheToKeep: Int)

This function is deprecated.

Unit
Unit
setTouchscreenBlocksFocus(touchscreenBlocksFocus: Boolean)
Unit
setTransitionGroup(isTransitionGroup: Boolean)
Unit
Boolean
Boolean
showContextMenuForChild(originalView: View!)
ActionMode!
startActionModeForChild(
    originalView: View!,
    callback: ActionMode.Callback!
)
Unit
Unit
Unit
Unit

Constants

ALIGN_BOUNDS

Added in 1.0.0
const val ALIGN_BOUNDS = 0: Int

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 getTop method is called.

See also
setAlignmentMode

ALIGN_MARGINS

Added in 1.0.0
const val ALIGN_MARGINS = 1: Int

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

BASELINE

Added in 1.0.0
const val BASELINEGridLayout.Alignment!

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
getBaseline

BOTTOM

Added in 1.0.0
const val BOTTOMGridLayout.Alignment!

Indicates that a view should be aligned with the bottom edges of the other views in its cell group.

CENTER

Added in 1.0.0
const val CENTERGridLayout.Alignment!

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

Added in 1.0.0
const val ENDGridLayout.Alignment!

Indicates that a view should be aligned with the end edges of the other views in its cell group.

FILL

Added in 1.0.0
const val FILLGridLayout.Alignment!

Indicates that a view should expanded to fit the boundaries of its cell group. This constant may be used in both rowSpecs and columnSpecs.

HORIZONTAL

Added in 1.0.0
const val HORIZONTAL = 0: Int

The horizontal orientation.

LEFT

Added in 1.0.0
const val LEFTGridLayout.Alignment!

Indicates that a view should be aligned with the left edges of the other views in its cell group.

RIGHT

Added in 1.0.0
const val RIGHTGridLayout.Alignment!

Indicates that a view should be aligned with the right edges of the other views in its cell group.

START

Added in 1.0.0
const val STARTGridLayout.Alignment!

Indicates that a view should be aligned with the start edges of the other views in its cell group.

TOP

Added in 1.0.0
const val TOPGridLayout.Alignment!

Indicates that a view should be aligned with the top edges of the other views in its cell group.

UNDEFINED

Added in 1.0.0
const val UNDEFINED = -2147483648: Int

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 MIN_VALUE) is intended to avoid confusion between valid values whose sign may not be known.

VERTICAL

Added in 1.0.0
const val VERTICAL = 1: Int

The vertical orientation.

Public constructors

GridLayout

Added in 1.0.0
GridLayout(context: Context!)

GridLayout

Added in 1.0.0
GridLayout(context: Context!, attrs: AttributeSet!)

GridLayout

Added in 1.0.0
GridLayout(context: Context!, attrs: AttributeSet!, defStyle: Int)

Public functions

generateLayoutParams

Added in 1.0.0
fun generateLayoutParams(attrs: AttributeSet!): GridLayout.LayoutParams!

getAlignmentMode

Added in 1.0.0
fun getAlignmentMode(): Int

Returns the alignment mode.

name android:alignmentMode

Returns
Int

the alignment mode; either ALIGN_BOUNDS or ALIGN_MARGINS

getColumnCount

Added in 1.0.0
fun getColumnCount(): Int

Returns the current number of columns. This is either the last value that was set with setColumnCount or, if no such value was set, the maximum value of each the upper bounds defined in columnSpec.

name android:columnCount

Returns
Int

the current number of columns

getOrientation

Added in 1.0.0
fun getOrientation(): Int

Returns the current orientation.

name android:orientation

Returns
Int

either HORIZONTAL or VERTICAL

See also
setOrientation

getPrinter

Added in 1.0.0
fun getPrinter(): Printer!

Return the printer that will log diagnostics from this layout.

Returns
Printer!

the printer associated with this view

See also
setPrinter

getRowCount

Added in 1.0.0
fun getRowCount(): Int

Returns the current number of rows. This is either the last value that was set with setRowCount or, if no such value was set, the maximum value of each the upper bounds defined in rowSpec.

name android:rowCount

Returns
Int

the current number of rows

See also
setRowCount
rowSpec

getUseDefaultMargins

Added in 1.0.0
fun getUseDefaultMargins(): Boolean

Returns whether or not this GridLayout will allocate default margins when no corresponding layout parameters are defined.

name android:useDefaultMargins

Returns
Boolean

true if default margins should be allocated

isColumnOrderPreserved

Added in 1.0.0
fun isColumnOrderPreserved(): Boolean

Returns whether or not column boundaries are ordered by their grid indices.

name android:columnOrderPreserved

Returns
Boolean

true if column boundaries must appear in the order of their indices, false otherwise

isRowOrderPreserved

Added in 1.0.0
fun isRowOrderPreserved(): Boolean

Returns whether or not row boundaries are ordered by their grid indices.

name android:rowOrderPreserved

Returns
Boolean

true if row boundaries must appear in the order of their indices, false otherwise

requestLayout

fun requestLayout(): Unit

setAlignmentMode

Added in 1.0.0
fun setAlignmentMode(alignmentMode: Int): Unit

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.

name android:alignmentMode

Parameters
alignmentMode: Int

either ALIGN_BOUNDS or ALIGN_MARGINS

setColumnCount

Added in 1.0.0
fun setColumnCount(columnCount: Int): Unit

ColumnCount is used only to generate default column/column indices when they are not specified by a component's layout parameters.

name android:columnCount

Parameters
columnCount: Int

the number of columns.

setColumnOrderPreserved

Added in 1.0.0
fun setColumnOrderPreserved(columnOrderPreserved: Boolean): Unit

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.

name android:columnOrderPreserved

Parameters
columnOrderPreserved: Boolean

use true to force GridLayout to respect the order of column boundaries.

setOrientation

Added in 1.0.0
fun setOrientation(orientation: Int): Unit

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 android.widget.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.

name android:orientation

Parameters
orientation: Int

either HORIZONTAL or VERTICAL

See also
getOrientation

setPrinter

Added in 1.0.0
fun setPrinter(printer: Printer!): Unit

Set the printer that will log diagnostics from this layout. The default value is created by android.util.LogPrinter.

Parameters
printer: Printer!

the printer associated with this layout

See also
getPrinter

setRowCount

Added in 1.0.0
fun setRowCount(rowCount: Int): Unit

RowCount is used only to generate default row/column indices when they are not specified by a component's layout parameters.

name android:rowCount

Parameters
rowCount: Int

the number of rows

See also
getRowCount
rowSpec

setRowOrderPreserved

Added in 1.0.0
fun setRowOrderPreserved(rowOrderPreserved: Boolean): Unit

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.

name android:rowOrderPreserved

Parameters
rowOrderPreserved: Boolean

true to force GridLayout to respect the order of row boundaries

setUseDefaultMargins

Added in 1.0.0
fun setUseDefaultMargins(useDefaultMargins: Boolean): Unit

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.

name android:useDefaultMargins

Parameters
useDefaultMargins: Boolean

use true to make GridLayout allocate default margins

spec

Added in 1.0.0
java-static fun spec(start: Int): GridLayout.Spec!

Return a Spec, spec, where:

  • spec.span = [start, start + 1]

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

Parameters
start: Int

the start index

See also
spec

spec

Added in 1.0.0
java-static fun spec(start: Int, alignment: GridLayout.Alignment!): GridLayout.Spec!

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: Int

the start index

alignment: GridLayout.Alignment!

the alignment

See also
spec

spec

Added in 1.0.0
java-static fun spec(start: Int, size: Int): GridLayout.Spec!

Return a Spec, spec, where:

  • spec.span = [start, start + size]

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

Parameters
start: Int

the start

size: Int

the size

See also
spec

spec

Added in 1.0.0
java-static fun spec(start: Int, weight: Float): GridLayout.Spec!

Equivalent to: spec(start, 1, weight).

Parameters
start: Int

the start

weight: Float

the weight

spec

Added in 1.0.0
java-static fun spec(start: Int, alignment: GridLayout.Alignment!, weight: Float): GridLayout.Spec!

Equivalent to: spec(start, 1, alignment, weight).

Parameters
start: Int

the start

alignment: GridLayout.Alignment!

the alignment

weight: Float

the weight

spec

Added in 1.0.0
java-static fun spec(start: Int, size: Int, alignment: GridLayout.Alignment!): GridLayout.Spec!

Equivalent to: spec(start, size, alignment, 0f).

Parameters
start: Int

the start

size: Int

the size

alignment: GridLayout.Alignment!

the alignment

spec

Added in 1.0.0
java-static fun spec(start: Int, size: Int, weight: Float): GridLayout.Spec!

Equivalent to: spec(start, 1, default_alignment, weight) - where default_alignment is specified in android.widget.GridLayout.LayoutParams.

Parameters
start: Int

the start

size: Int

the size

weight: Float

the weight

spec

Added in 1.0.0
java-static fun spec(start: Int, size: Int, alignment: GridLayout.Alignment!, weight: Float): GridLayout.Spec!

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: Int

the start

size: Int

the size

alignment: GridLayout.Alignment!

the alignment

weight: Float

the weight

Protected functions

checkLayoutParams

protected fun checkLayoutParams(p: ViewGroup.LayoutParams!): Boolean

generateDefaultLayoutParams

Added in 1.0.0
protected fun generateDefaultLayoutParams(): GridLayout.LayoutParams!

generateLayoutParams

Added in 1.0.0
protected fun generateLayoutParams(lp: ViewGroup.LayoutParams!): GridLayout.LayoutParams!

onLayout

protected fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int): Unit

onMeasure

protected fun onMeasure(widthSpec: Int, heightSpec: Int): Unit