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:

import androidx.ui.foundation.Box
import androidx.ui.layout.Center
import androidx.ui.layout.LayoutSize

Center {
    Box(LayoutSize(width = 100.dp, height = 100.dp), backgroundColor = Color.Red)
}

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.

Properties

Dp

Dp

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:

import androidx.ui.foundation.Box
import androidx.ui.layout.Center
import androidx.ui.layout.LayoutSize

Center {
    Box(LayoutSize(width = 100.dp, height = 100.dp), backgroundColor = Color.Red)
}

Properties

height

val height: Dp

width

val width: Dp