Arun
03/04/2021, 4:07 PMBox
items. Let’s say I have the following. How do I make sure the Box
child composables are perfect squares? What value do I have to set it’s height
to?
@Composable
@Preview
fun PreviewSquareItems() {
Row(modifier = Modifier.fillMaxWidth()) {
val total = 2
repeat(total) { index ->
Box(
modifier = Modifier
.weight(1f)
.height(245.dp) // how to find this height?
.clip(RoundedCornerShape(8.dp))
.background(color = Color.Blue),
)
if (index + 1 < total) {
Spacer(modifier = Modifier.width(10.dp))
}
}
}
}
Se7eN
03/04/2021, 4:08 PMModifier.aspectRatio(1f)