简体   繁体   English

Jetpack Compose 中的动画重组(视图更改)

[英]Animate recomposition (view changes) in Jetpack Compose

Is there a way to automatically animate composition changes in a Jetpack Compose @Composable ?有没有办法在 Jetpack Compose @Composable中自动为构图变化设置动画? For instance, if a previously shown widget is removed in a recomposition, can a fade-out animation be applied automatically?例如,如果在重组中删除了先前显示的小部件,是否可以自动应用淡出 animation? I'm thinking something similar to Android View 's animateLayoutChanges .我在想类似于 Android ViewanimateLayoutChanges的东西。

Yes, you can use:是的,您可以使用:

val visible by remember { mutableStateOf(false) }
AnimatedVisibility(visible = visible) {
    // Composables Here 
}

Or for the specific animation you asked for, surround the Composable (s) with CrossFade或者对于您要求的特定 animation,用CrossFade围绕 Composable (s)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM