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

LayoutPadding

data class LayoutPadding : LayoutModifier
kotlin.Any
   ↳ androidx.ui.layout.LayoutPadding

A LayoutModifier that adds start, top, end and bottom padding to the wrapped layout. The requested padding will be subtracted from the available space before the wrapped layout has the chance to choose its own size, so conceptually the padding has higher priority to occupy the available space than the content. If you only need to modify the position of the wrapped layout without affecting its size as described above, you should use the LayoutOffset modifier instead. Also note that padding must be non-negative. If you consider using negative (or positive) padding to offset the wrapped layout, LayoutOffset should be used.

Example usage:


//Unresolved: androidx.ui.layout.samples.LayoutPaddingModifier

Summary

Public constructors

<init>(start: Dp = 0.dp, top: Dp = 0.dp, end: Dp = 0.dp, bottom: Dp = 0.dp)

A LayoutModifier that adds start, top, end and bottom padding to the wrapped layout.

Public methods

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

Modifies constraints for performing measurement of the modified layout element.

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.

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.

Properties

Dp

Dp

Dp

Dp

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 constructors

<init>

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

A LayoutModifier that adds start, top, end and bottom padding to the wrapped layout. The requested padding will be subtracted from the available space before the wrapped layout has the chance to choose its own size, so conceptually the padding has higher priority to occupy the available space than the content. If you only need to modify the position of the wrapped layout without affecting its size as described above, you should use the LayoutOffset modifier instead. Also note that padding must be non-negative. If you consider using negative (or positive) padding to offset the wrapped layout, LayoutOffset should be used.

Example usage:


//Unresolved: androidx.ui.layout.samples.LayoutPaddingModifier

See Also

Public methods

modifyConstraints

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

Modifies constraints for performing measurement of the modified layout element.

modifyPosition

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

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.

Properties

bottom

val bottom: Dp

end

val end: Dp

start

val start: Dp

top

val top: Dp