I basically have the same problem as this post, except I'm using Jetpack Compose, instead of the old View model. It happens with any kind of content - I tested it with a simple Text
composable. Here's how to reproduce it:
Text
composable to display a string that ends up making it 6 lines highText
composable stays at the previous level, and the bottom "jumps" up for a split second to make up the height difference. Then the whole composable drops back down, and ends up at the bottom of the screen, where it was supposed to have been all alongThis only happens when the new content is shorter in height then the original (that's why I tested it with 6 lines worth of text changing to 1 line). The original post I referenced says that the solution is to setandroid:animateLayoutChanges = "false"
, however, I don't see any equivalent in Compose. There's a modifier for animateContentSize
, but it's only to enable animation. I don't see any option to disable it.
Here's my sample code:
ModalBottomSheetLayout(
sheetContent = {
var text by remember{ mutableStateOf("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum")}
Text(text = text, Modifier.clickable {
text = "a much shorter line of text"
})
},
sheetShape = RoundedCornerShape(12.dp),
) { ... }
It's a bug in ModalBottomSheetLayout → https://issuetracker.google.com/258744762
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With