`我正在尝试使用state.animateScrollItems((函数为LazyColumn项设置动画。但不起作用。它与state.scrollItmes((函数配合使用非常好。
我使用的是compose_ui_verdion 1.2.1、compose_compailer_version 1.3.2和kotlin version 1.7.20
LazyColumn(
horizontalAlignment = Alignment.CenterHorizontally,
state = state
) {
item {
Box(
modifier = Modifier
.fillMaxWidth()
.background(Color(color = 0x93F1ECEC)),
contentAlignment = Alignment.TopCenter
) {
Text(
text = "Enter purchase details :",
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 4.dp, horizontal = 4.dp),
color = MaterialTheme.colors.error
)
}
}
item {
FirstThreeRows {
}
}
item {
Spacer(modifier = Modifier.height(10.dp))
}
item {
ProductListTitle()
}
item {
ProductList() // it is another lazycolumn
}
item {
ItemSelectionRows { focused ->
Log.i(TAG, "HomeScreen2: $focused")
if (focused) {
coroutineScope.launch {
state.animateScrollToItem(2)
}
} else {
coroutineScope.launch {
state.animateScrollToItem(0)
}
}
}
}
item {
ProductButtonRow()
}
item {
ProductPriceColumn()
}
item {
Spacer(modifier = Modifier.height(10.dp))
}
item {
Button(onClick = { /*TODO*/ }) {
Text(text = "Submit")
}
}
item {
Spacer(modifier = Modifier.height(300.dp))
}
}
请给我一个解决方案。">
我认为您需要将state
更改为listState
以与参数区分
val listState=rememberLazyListState((