Chris Fillmore
09/27/2022, 9:41 PMgraphicsLayer
or otherwise) and also have it scale down the amount of space it occupies?Chris Fillmore
09/27/2022, 9:48 PMStylianos Gakis
09/27/2022, 11:21 PMStylianos Gakis
09/27/2022, 11:22 PMChris Fillmore
09/27/2022, 11:35 PMval width = ...
val height = ...
val scale = ...
Box(
Modifier
.size(width = width * scale, height = height * scale)
.wrapContentSize(unbounded = true)
) {
Surface(
Modifier
.size(width, height)
.scale(scale)
) { ... }
}
Stylianos Gakis
09/28/2022, 12:03 AMChris Fillmore
09/28/2022, 12:05 AM0.5f
is applied, there’s nothing thereChris Fillmore
09/28/2022, 12:05 AMStylianos Gakis
09/28/2022, 7:35 AMChris Fillmore
09/28/2022, 2:31 PM@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
.