Grigorii Yurkov
11/03/2020, 6:35 PMRow
doesn't want to get recomposed even after his child Text
become bigger. Should I recompose it manually? If yes, how can I do it?Afzal Najam
11/03/2020, 6:36 PMGrigorii Yurkov
11/03/2020, 6:37 PMAdam Powell
11/03/2020, 7:03 PMText
to become bigger? Did the content of the Text
change or something else?Row
to not recompose if the layout size of one of its children changes. It will relayout, but not recompose.Grigorii Yurkov
11/03/2020, 7:09 PMText
with more symbolsAdam Powell
11/03/2020, 7:10 PMGrigorii Yurkov
11/03/2020, 7:12 PM@OptIn(ExperimentalAnimationApi::class)
@Preview
@Composable
fun MyTest() {
var text by remember { mutableStateOf("0") }
var visible by remember { mutableStateOf(false) }
TestTheme {
Row(modifier = Modifier.fillMaxWidth().height(30.dp)) {
Spacer(
modifier = Modifier.weight(1f).background(Color.Red).height(30.dp).clickable(
onClick = {
visible = true
}
)
)
AnimatedVisibility(visible = visible) {
Text(text, modifier = Modifier.clickable {
text += "0"
})
}
}
}
}
I finally finished. That was much harder that I thoughtvisible
init value is true
, all work fine, but if it is false
and than we set it to true, it doesn't work fineAdam Powell
11/03/2020, 8:10 PMAnimatedVisibility
to recompose for the new text, and the row to remeasure+relayout for the changed text content, but not recompose the row.Grigorii Yurkov
11/03/2020, 8:11 PMText
Spacer
remains the same sizeAdam Powell
11/03/2020, 8:15 PMAnimatedVisibility
?Grigorii Yurkov
11/03/2020, 8:20 PMfalse
and back to true
must not change behaviourDoris Liu
11/03/2020, 8:31 PMAnimatedVisibility
. Could you file a bug please?AnimatedVisibilty
?Grigorii Yurkov
11/03/2020, 8:33 PMDoris Liu
11/03/2020, 8:37 PMGrigorii Yurkov
11/03/2020, 8:40 PMDoris Liu
11/03/2020, 8:49 PMModifier.animateContentSize()
for that purpose. 🙂Text(text, modifier = Modifier.clickable {
text += "0"
}.animateContentSize() )
Hitanshu Dhawan
11/07/2020, 4:33 PMModifier.animateContentSize()
The problem I am facing is that the text is changed first and then the size changes, see the transition from Added to Add. Is this the intended behaviour?
What’s the best way to achieve this interaction? Can I use PropKeys here?Doris Liu
11/07/2020, 8:08 PMAnimationSpec
in animateContentSize
if you need to coordinate them. Alternatively, you could consider animating the check mark in AnimatedVisibility
using fade and expand/shrink to add a little more dynamic to the animation. 🙂Hitanshu Dhawan
11/07/2020, 8:19 PMThe intended behavior is to change the content (in this case the text) immediately and animate the container size afterwards.In my case I may want the content to change afterwards, is this achievable? or any other way to achieve this interaction?
Doris Liu
11/07/2020, 8:27 PMAnimatedVisibility
😂Hitanshu Dhawan
11/07/2020, 8:45 PM