We just launched Compose Examples featuring over 150+ components! Check it out →

scale

Common

Modifier in Compose Ui

Scale the contents of the composable by the following scale factors along the horizontal and vertical axis respectively. Negative scale factors can be used to mirror content across the corresponding horizontal or vertical axis.

Last updated:

Installation

dependencies {
   implementation("androidx.compose.ui:ui:1.8.0-alpha01")
}

Overloads

@Stable
fun Modifier.scale(scaleX: Float, scaleY: Float)

Parameters

namedescription
scaleXMultiplier to scale content along the horizontal axis
scaleYMultiplier to scale content along the vertical axis
@Stable
fun Modifier.scale(scale: Float)

Parameters

namedescription
scaleMultiplier to scale content along the horizontal and vertical axis

Code Examples

ScaleNonUniformSample

@Composable
fun ScaleNonUniformSample() {
    Box(Modifier.scale(scaleX = 2f, scaleY = 3f).size(100.dp, 100.dp))
}

ScaleUniformSample

@Composable
fun ScaleUniformSample() {
    Box(Modifier.scale(2f).size(100.dp, 100.dp))
}
by @alexstyl