Matej Drobnič
09/04/2020, 12:48 PMRecylerView
does when you add/remove/update/move items around. Is this even possible at this moment?Vinay Gaba
09/04/2020, 3:48 PMAnimatedVisibility
composable helps with this. Here’s an example where I animate the deletion of a row - https://github.com/vinaygaba/Learn-Jetpack-Compose-By-Example/blob/master/app/src/main/java/com/example/jetpackcompose/animation/ListAnimationActivity.ktMatej Drobnič
09/05/2020, 4:40 AManimSpec
seems to workVinay Gaba
09/07/2020, 5:18 PMhttps://github.com/vinaygaba/Learn-Jetpack-Compose-By-Example/raw/master/screenshots/list_animation.gif▾
Matej Drobnič
09/08/2020, 9:05 AMJulianK
01/11/2021, 10:32 AM@OptIn(ExperimentalAnimationApi::class)
@Composable
fun ItemRow(
item:Any,
deleteItem: (Any) -> Unit
) {
var visibility by remember(item) {mutableStateOf(true)}
if (!visibility) {
LaunchedEffect(subject = item) {
delay(500)
deleteItem(item)
}
}
AnimatedVisibility(visible = visibility,
enter = fadeIn(initialAlpha = 1f), // fake no animation
exit = shrinkVertically(animSpec = tween(durationMillis = 500)) + fadeOut()
) {
/** Row content with delete handler, onDelete = {visibility = false} **/
}
}
Is there currently a better solution for this?