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

LayoutWidth

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

Modifies the width of a Compose UI layout element. LayoutWidth(16.dp) will instruct the layout element to be exactly 16dp wide 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 width of a layout element within a range rather than to an exact size. See LayoutHeight to modify height, 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.LayoutAspectRatio
import androidx.ui.layout.LayoutWidth

Center {
    Box(LayoutWidth(100.dp) + LayoutAspectRatio(1f), backgroundColor = Color.Magenta)
}

Summary

Nested classes

data

Modifies the width of a Compose UI layout element to be at least minWidth and at most maxWidth wide if permitted by its parent.

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

data

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

data

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

Public constructors

<init>(width: Dp)

Modifies the width of a Compose UI layout element.

Properties

Dp

Public constructors

<init>

LayoutWidth(width: Dp)

Modifies the width of a Compose UI layout element. LayoutWidth(16.dp) will instruct the layout element to be exactly 16dp wide 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 width of a layout element within a range rather than to an exact size. See LayoutHeight to modify height, 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.LayoutAspectRatio
import androidx.ui.layout.LayoutWidth

Center {
    Box(LayoutWidth(100.dp) + LayoutAspectRatio(1f), backgroundColor = Color.Magenta)
}

Properties

width

val width: Dp