Compose Modifier
Common
fun Modifier.scale(scaleX: Float, scaleY: Float) =
    if (scaleX != 1.0f || scaleY != 1.0f) {
        graphicsLayer(scaleX = scaleX, scaleY = scaleY)
    } else {
        this
    }

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.

Usage of this API renders this composable into a separate graphics layer

Parameters

scaleX Multiplier to scale content along the horizontal axis
scaleY Multiplier to scale content along the vertical axis
Common
fun Modifier.scale(scale: Float) = scale(scale, scale)

Scale the contents of both the horizontal and vertical axis uniformly by the same scale factor.

Usage of this API renders this composable into a separate graphics layer

Parameters

scale Multiplier 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))
}