将列的第 5 项或 lazyColumn 固定在屏幕顶部,同时使用 android jetpack compose 滚动列

Pin the 5th item of the column or lazyColumn on top of the screen while scrolling the column using android jetpack compose

提问人:Arun Aditya 提问时间:6/22/2023 更新时间:6/22/2023 访问量:418

问:

我是android jetpack compose的新手,我使用lazyColumn创建了一个列表视图,该视图工作正常 但我的用例是将第 5 个或第 X 个元素固定到屏幕顶部,而其他元素将滚动。

Android android-jetpack-compose android-appcompat android-compose-card

评论


答:

1赞 Kashif Masood 6/22/2023 #1

你可以用它来做这个。stickyheader

LazyColumn() {
     stickyheader {
         //your xth element
     }
     //your rest of the items
}

它将始终粘在惰性列的顶部,而其余项目将能够在其下方滚动。