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

LayoutSize

@Stable data class LayoutSize : LayoutModifier
kotlin.Any
   ↳ androidx.ui.layout.LayoutSize

Modifies the width and height of a Compose UI layout element together. LayoutSize(24.dp, 16.dp) will instruct the layout element to be exactly 24dp wide and 16dp tall if permitted by its parent.

This modifies the incoming Constraints provided by a layout element's parent. If the incoming constraints do not allow the modified size, the incoming constraints from the parent will restrict the final size.

See Min, Max, Constrain and Fill to modify the height of a layout element within a range rather than to an exact size. See LayoutWidth to modify width, or LayoutSize to modify both width and height at once.

Example usage:


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

Summary

Nested classes

data

Modifies the height of a Compose UI layout element to be at least minWidth wide and minHeight tall, and at most minWidth wide and maxHeight tall if permitted by its parent.

Modifies the size of a Compose UI layout element to fill all available space.

data

Modifies the size of a Compose UI layout element to be at most maxWidth wide and maxHeight tall if permitted by its parent.

data

Modifies the size of a Compose UI layout element to be at least minWidth wide and minHeight tall if permitted by its parent.

Public constructors

<init>(size: Dp)

Modifies a Compose UI layout element to have a square size of size.

<init>(width: Dp, height: Dp)

Modifies the width and height of a Compose UI layout element together.

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

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>

LayoutSize(size: Dp)

Modifies a Compose UI layout element to have a square size of size.

<init>

LayoutSize(
    width: Dp,
    height: Dp)

Modifies the width and height of a Compose UI layout element together. LayoutSize(24.dp, 16.dp) will instruct the layout element to be exactly 24dp wide and 16dp tall if permitted by its parent.

This modifies the incoming Constraints provided by a layout element's parent. If the incoming constraints do not allow the modified size, the incoming constraints from the parent will restrict the final size.

See Min, Max, Constrain and Fill to modify the height of a layout element within a range rather than to an exact size. See LayoutWidth to modify width, or LayoutSize to modify both width and height at once.

Example usage:


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

Properties

height

val height: Dp

width

val width: Dp