android Jetpack Compose:无法在LazyVerticalStaggeredGrid中执行Modifier.animateItemPlacement()

1wnzp6jl  于 2023-11-15  发布在  Android
关注(0)|答案(1)|浏览(120)

我尝试使用Modifier.animateItemPlacement()修饰符对LazyVerticalStaggeredGrid中的元素进行动画处理,但出现错误:
"Cannot access 'LazyGridItemScopeImpl': it is internal in 'androidx.compose.foundation.lazy.grid'"
我的代码:

import androidx.compose.foundation.lazy.grid.LazyGridItemScopeImpl.animateItemPlacement

LazyVerticalStaggeredGrid(
    columns = StaggeredGridCells.Adaptive(150.dp),
    modifier = Modifier.fillMaxSize()
) {
    items(noteItems.value.size, key = { noteItems.value[it].id!! }) { item ->
        NoteItem(modifier = Modifier.animateItemPlacement(), noteItems.value[item])
    }
}

字符串
网上没有信息,我不知道该怎么办

w6lpcovy

w6lpcovy1#

我试过你的代码和所有的工作正常.这是我的依赖.

val navVersion = "2.6.0"
    implementation("androidx.navigation:navigation-compose:$navVersion")

    val compose_version= "1.5.4"
    implementation("androidx.compose.ui:ui:$compose_version")
    implementation("androidx.compose.material:material:$compose_version")
    implementation("androidx.compose.ui:ui-tooling:$compose_version")
    implementation("androidx.constraintlayout:constraintlayout-compose:1.0.1")

    implementation("androidx.compose.material3:material3-android:1.2.0-alpha10")

    implementation("androidx.activity:activity-compose:1.8.0")

字符串
你能分享一下你的依赖吗?

相关问题