Mohamed Elfiky
08/21/2020, 9:00 AMLazyColumn(modifier = Modifier.fillMaxWidth()) {
items((0..30).toList()) {
var isExpanded by remember { mutableStateOf(false) }
Surface(
color = MaterialTheme.colors.primary,
shape = CircleShape
) {
Row(modifier = Modifier.animateContentSize()) {
IconButton(onClick = { isExpanded = !isExpanded }) {
Icon(asset = Icons.Default.AccessTime, tint = Color.White)
}
if (isExpanded) {
Text(
modifier = Modifier.gravity(Alignment.CenterVertically)
.padding(end = 16.dp),
text = "some text",
style = MaterialTheme.typography.caption,
color = Color.White
)
}
}
}
Spacer(modifier = Modifier.height(8.dp))
}
}
this code make the icons disappear on scrolling and is very lag, but when i put the animateContentSize on the surface it works but the animation is not like the above one. this code is put in another compose but i extract it to see the problem.Zach Klippenstein (he/him) [MOD]
08/21/2020, 4:26 PMAnimatedVisibility
for this? Instead of if (isExpanded)
(or in addition too, don't remember the exact API).Mohamed Elfiky
08/21/2020, 4:41 PMZach Klippenstein (he/him) [MOD]
08/21/2020, 4:43 PMMohamed Elfiky
08/21/2020, 4:46 PMDoris Liu
08/21/2020, 5:50 PManimateContentSize()
on the child/children of Surface instead of on Surface directly, as Surface does it's shape clipping and shadow drawing after animateContentSize()
That means the clipping logic inside of animateContentSize
will interfere with those. That's the only caveat that I know of. I'll add that to the kdoc, until we work out a solution for Surface.ScrollableColumn
instead of a LazyColumn
. It may be an issue in LazyColumn
. Could you file a bug for this please? 🙂Mohamed Elfiky
08/22/2020, 8:08 AMDoris Liu
08/22/2020, 5:22 PManimateContentSize
seems to report the right size (i.e. the size is always between the icon size and the full size). Unclear why the icon doesn't show sometimes. Will investigate further.Mohamed Elfiky
08/22/2020, 5:35 PM