Peter
10/18/2024, 12:30 PM@Composable
@Preview
private fun TestPreview() {
var isShown by remember { mutableStateOf(true) }
LaunchedEffect(Unit) {
while (true) {
delay(1000)
isShown = !isShown
}
}
Row(Modifier.animateContentSize()) {
if (isShown) {
Box(modifier = Modifier.background(Color.Red)
.height(200.dp)
.animateContentSize()
.weight(1f)
)
}
Box(modifier = Modifier.background(Color.Blue)
.height(200.dp)
.animateContentSize()
.weight(1f)
)
}
}
Stylianos Gakis
10/18/2024, 12:36 PMweight(1f)
with a if (isShown) Modifier.weight(1f) else Modifier.width(0.dp)
and removed the outer if statement so it is also in composition it might also animatePeter
10/18/2024, 12:43 PMweight()
?
Row(Modifier.animateContentSize()) {
Box(
modifier = Modifier.background(Color.Red)
.height(200.dp)
.animateContentSize()
.let {
if (isShown) {
it.weight(1f)
} else {
it.width(0.dp)
}
}
)
Box(
modifier = Modifier
.background(Color.Blue)
.height(200.dp)
.animateContentSize()
.weight(1f)
)
}
Stylianos Gakis
10/18/2024, 12:46 PMPeter
10/18/2024, 12:51 PManimateContentSize()
in every possible way, doesn't helpPeter
10/18/2024, 12:53 PMweight()
, only width()
Stylianos Gakis
10/18/2024, 12:53 PMStylianos Gakis
10/18/2024, 12:53 PMPeter
10/18/2024, 12:53 PMStylianos Gakis
10/18/2024, 12:55 PMBox(
modifier = Modifier.weight(1f)
) {
Box(
Modifier
.background(Color.Blue)
.matchParentSize()
.animateContentSize()
)
}
Or is it synced with the parent anyway due to matchParentSize()?Peter
10/18/2024, 1:04 PM