The second Android 11 Developer Preview is now available, test it out and share your feedback.

LayoutModifier

interface LayoutModifier : Modifier.Element
androidx.ui.core.LayoutModifier

A Modifier.Element that changes the way a UI component is measured and laid out.

Summary

Public methods

open IntPx
Density.maxIntrinsicHeightOf(measurable: Measurable, width: IntPx, layoutDirection: LayoutDirection)

Determines the modified maximum intrinsic height of measurable.

open IntPx
Density.maxIntrinsicWidthOf(measurable: Measurable, height: IntPx, layoutDirection: LayoutDirection)

Determines the modified maximum intrinsic width of measurable.

open IntPx
Density.minIntrinsicHeightOf(measurable: Measurable, width: IntPx, layoutDirection: LayoutDirection)

Determines the modified minimum intrinsic height of measurable.

open IntPx
Density.minIntrinsicWidthOf(measurable: Measurable, height: IntPx, layoutDirection: LayoutDirection)

Determines the modified minimum intrinsic width of measurable.

open IntPx?
Density.modifyAlignmentLine(line: AlignmentLine, value: IntPx?, layoutDirection: LayoutDirection)

Returns the modified position of line given its unmodified value.

open Constraints
Density.modifyConstraints(constraints: Constraints, layoutDirection: LayoutDirection)

Modifies constraints for performing measurement of the modified layout element.

open LayoutDirection

Modifies the layout direction to be used for measurement and layout by the modified element.

open IntPxPosition
Density.modifyPosition(childSize: IntPxSize, containerSize: IntPxSize, layoutDirection: LayoutDirection)

Returns the position of a modified child of size childSize within a container of size containerSize.

open IntPxSize
Density.modifySize(constraints: Constraints, layoutDirection: LayoutDirection, childSize: IntPxSize)

Returns the container size of a modified layout element given the original container measurement constraints and the measured childSize.

Inherited functions

Inherited extension functions

From androidx.ui.layout
Modifier
Modifier.absolutePadding(left: Dp = 0.dp, top: Dp = 0.dp, right: Dp = 0.dp, bottom: Dp = 0.dp)

Apply additional space along each edge of the content in Dp: left, top, right and bottom.

Modifier

Attempts to size the content to match a specified aspect ratio by trying to match one of the incoming constraints in the following order: Constraints.maxWidth, Constraints.maxHeight, Constraints.minWidth, Constraints.minHeight.

Modifier

Have the content fill the Constraints.maxHeight of the incoming measurement constraints by setting the minimum height to be equal to the maximum height.

Modifier

Have the content fill the Constraints.maxWidth and Constraints.maxHeight of the incoming measurement constraints by setting the minimum width to be equal to the maximum width and the minimum height to be equal to the maximum height.

Modifier

Have the content fill the Constraints.maxWidth of the incoming measurement constraints by setting the minimum width to be equal to the maximum width.

Modifier
Modifier.offset(x: Dp, y: Dp)

Offset the content by (xdp, ydp).

Modifier
Modifier.padding(start: Dp = 0.dp, top: Dp = 0.dp, end: Dp = 0.dp, bottom: Dp = 0.dp)

Apply additional space along each edge of the content in Dp: start, top, end and bottom.

Modifier

Apply alldp of additional space along each edge of the content, left, top, right and bottom.

Modifier

Declare the preferred height of the content to be exactly heightdp.

Modifier
Modifier.preferredHeightIn(minHeight: Dp = Dp.Unspecified, maxHeight: Dp = Dp.Unspecified)

Constrain the height of the content to be between minHeightdp and maxHeightdp as permitted by the incoming measurement Constraints.

Modifier

Declare the preferred size of the content to be exactly sizedp square.

Modifier
Modifier.preferredSize(width: Dp, height: Dp)

Declare the preferred size of the content to be exactly widthdp by heightdp.

Modifier
Modifier.preferredSizeIn(minWidth: Dp = Dp.Unspecified, minHeight: Dp = Dp.Unspecified, maxWidth: Dp = Dp.Unspecified, maxHeight: Dp = Dp.Unspecified)

Constrain the width of the content to be between minWidthdp and maxWidthdp and the height of the content to be between minHeight and maxHeight as permitted by the incoming measurement Constraints.

Modifier

Constrain the size of the content to be within constraints as permitted by the incoming measurement Constraints.

Modifier

Declare the preferred width of the content to be exactly widthdp.

Modifier
Modifier.preferredWidthIn(minWidth: Dp = Dp.Unspecified, maxWidth: Dp = Dp.Unspecified)

Constrain the width of the content to be between minWidthdp and maxWidthdp as permitted by the incoming measurement Constraints.

Modifier

Allow the content to measure at its desired height without regard for the incoming measurement minimum height constraint.

Modifier
Modifier.wrapContentSize(align: Alignment = Center)

Allow the content to measure at its desired size without regard for the incoming measurement minimum width or minimum height constraints.

Modifier
Modifier.wrapContentWidth(align: Alignment = Center)

Allow the content to measure at its desired width without regard for the incoming measurement minimum width constraint.

From androidx.ui.core
Modifier

Clip the content to shape.

Modifier

Clip the content to the bounds of a layer defined at this modifier.

Modifier
Modifier.drawBehind(onDraw: Density.(canvas: Canvas, size: PxSize) -> Unit)

Draw into a Canvas behind the modified content.

Modifier
Modifier.drawLayer(scaleX: Float = 1f, scaleY: Float = 1f, alpha: Float = 1f, translationX: Float = 0f, translationY: Float = 0f, elevation: Float = 0f, rotationX: Float = 0f, rotationY: Float = 0f, rotationZ: Float = 0f, transformOrigin: TransformOrigin = TransformOrigin.Center, outlineShape: Shape? = null, clipToBounds: Boolean = true, clipToOutline: Boolean = true)

Draw the content into a layer.

Modifier

Draw content with modified opacity (alpha) that may be less than 1.

Modifier
Modifier.drawShadow(shape: Shape, elevation: Dp, clipToOutline: Boolean = true, opacity: Float = 1f)

Creates a DrawLayerModifier that draws the shadow.

Modifier
Modifier.onChildPositioned(onChildPositioned: (LayoutCoordinates) -> Unit)

Invoke onChildPositioned with the LayoutCoordinates of each child element after each one is positioned.

Modifier

Invoke onPositioned with the LayoutCoordinates of the element after positioning.

Modifier
Modifier.paint(painter: Painter, sizeToIntrinsics: Boolean = true, alignment: Alignment = Alignment.Center, scaleFit: ScaleFit = ScaleFit.Fit, alpha: Float = DefaultAlpha, colorFilter: ColorFilter? = null, rtl: Boolean = false)

Paint the content using painter.

Modifier

Tag the element with tag to identify the element within its parent.

From androidx.ui.foundation
Modifier

Draws shape with paint behind the content.

Modifier
Modifier.drawBackground(color: Color, shape: Shape = RectangleShape)

Draws shape with a solid color behind the content.

Modifier
Modifier.drawBackground(brush: Brush, shape: Shape = RectangleShape)

Draws shape with brush behind the content.

From androidx.ui.graphics.vector
Modifier
Modifier.drawVector(defaultWidth: Px, defaultHeight: Px, viewportWidth: Float = defaultWidth.value, viewportHeight: Float = defaultHeight.value, tintColor: Color = DefaultTintColor, tintBlendMode: BlendMode = DefaultTintBlendMode, alignment: Alignment = DefaultAlignment, scaleFit: ScaleFit = ScaleFit.Fit, name: String = "", children: VectorScope.(viewportWidth: Float, viewportHeight: Float) -> Unit)

Modifier to draw a vector graphic with the provided width, height and viewport dimensions

From androidx.ui.material.ripple
Modifier
Modifier.ripple(bounded: Boolean = true, radius: Dp? = null, color: Color? = null, enabled: Boolean = true, clock: AnimationClockObservable = AnimationClockAmbient.current)

Ripple is a Modifier which draws the visual indicator for a pressed state.

Inherited extension properties

From androidx.ui.layout
Modifier

Changes the LayoutDirection of the content to LayoutDirection.Ltr.

Modifier

Changes the LayoutDirection of the content to LayoutDirection.Rtl.

Public methods

maxIntrinsicHeightOf

open fun Density.maxIntrinsicHeightOf(
    measurable: Measurable,
    width: IntPx,
    layoutDirection: LayoutDirection
): IntPx

Determines the modified maximum intrinsic height of measurable. See Measurable.maxIntrinsicHeight.

maxIntrinsicWidthOf

open fun Density.maxIntrinsicWidthOf(
    measurable: Measurable,
    height: IntPx,
    layoutDirection: LayoutDirection
): IntPx

Determines the modified maximum intrinsic width of measurable. See Measurable.maxIntrinsicWidth.

minIntrinsicHeightOf

open fun Density.minIntrinsicHeightOf(
    measurable: Measurable,
    width: IntPx,
    layoutDirection: LayoutDirection
): IntPx

Determines the modified minimum intrinsic height of measurable. See Measurable.minIntrinsicHeight.

minIntrinsicWidthOf

open fun Density.minIntrinsicWidthOf(
    measurable: Measurable,
    height: IntPx,
    layoutDirection: LayoutDirection
): IntPx

Determines the modified minimum intrinsic width of measurable. See Measurable.minIntrinsicWidth.

modifyAlignmentLine

open fun Density.modifyAlignmentLine(
    line: AlignmentLine,
    value: IntPx?,
    layoutDirection: LayoutDirection
): IntPx?

Returns the modified position of line given its unmodified value.

modifyConstraints

open fun Density.modifyConstraints(
    constraints: Constraints,
    layoutDirection: LayoutDirection
): Constraints

Modifies constraints for performing measurement of the modified layout element.

modifyLayoutDirection

open fun Density.modifyLayoutDirection(layoutDirection: LayoutDirection): LayoutDirection

Modifies the layout direction to be used for measurement and layout by the modified element.

modifyPosition

open fun Density.modifyPosition(
    childSize: IntPxSize,
    containerSize: IntPxSize,
    layoutDirection: LayoutDirection
): IntPxPosition

Returns the position of a modified child of size childSize within a container of size containerSize.

modifySize

open fun Density.modifySize(
    constraints: Constraints,
    layoutDirection: LayoutDirection,
    childSize: IntPxSize
): IntPxSize

Returns the container size of a modified layout element given the original container measurement constraints and the measured childSize.