kc_*_*dev 6 android-jetpack-compose
我正在尝试动画添加/删除项目LazyList。这篇文章建议我使用LazyItemScope$Modifier.animateItemPlacement(),但我遇到了问题。
我正在使用 Jetpack Compose 版本1.1.0-beta03。这是我正在使用的代码片段:
@ExperimentalFoundationApi
@ExperimentalAnimationApi
@ExperimentalMaterialApi
@Composable
fun NotificationList(
listState: LazyListState,
notifications: List<Notification>
) {
Surface(modifier = Modifier.fillMaxSize()) {
LazyColumn(state = listState) {
itemsIndexed(
items = notifications,
key = { _, listItem -> listItem.hashCode() }
) { _, notification ->
// ...
SwipeToDismiss(
modifier = Modifier.animateItemPlacement(),
// ...
)
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是,我的应用程序在启动时崩溃了。以下是我在控制台中看到的内容。有谁知道我做错了什么或如何解决?
E/AndroidRuntime:致命异常:主进程:com.somecompany.someapp,PID:22108 java.lang.NoSuchMethodError:没有静态方法 AnimatedContent(Landroidx/compose/animation/core/Transition;Landroidx/compose/ui/Modifier;Lkotlin/ jvm/functions/Function1;Landroidx/compose/ui/Alignment;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;II)V 类 Landroidx/compose/animation/AnimatedContentKt; 或其超类(“androidx.compose.animation.AnimatedContentKt”的声明出现在 com.google.accompanist.navigation.animation.AnimatedNavHostKt 的 /data/app/com.somecompany.someapp-zQWcLTjkBOQqglBKnmHLIg==/base.apk 中)。 AnimatedNavHost(AnimatedNavHost.kt:242) 在 com.somecompany.someapp.MainActivity2$onCreate$1$1$1$5.invoke(MainActivity2.kt:78) 在 ...
| 归档时间: |
|
| 查看次数: |
1517 次 |
| 最近记录: |