Currently I’m only dealing with scale < 1.0f. It’s possible the behaviour at scale > 1.0f is undesirable, I haven’t tested. Also it’s possible that each use case will need to manage e.g. padding and such, in case the boundaries look bad. I don’t know what will happen here. So far in my use case it looks good, but I can’t say for sure it applies to all use cases generally.
If you want to check it out, I extracted a utility:
@Composable
fun ScaledLayout(
scale: Float,
width: Dp,
height: Dp,
content: @Composable () -> Unit,
) {
Box(
modifier = Modifier
.size(width = width * scale, height = height * scale)
.wrapContentSize(unbounded = true),
contentAlignment = Alignment.Center,
) {
content()
}
}
The
content
still needs to apply the same size and scale on its own, to achieve the right effect. The “ScaledLayout” just provides it a layout container that will fit the provided
scale
.