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

huangapple go评论82阅读模式
英文:

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

问题

我是新手在Android Jetpack Compose中,我使用lazyColumn创建了一个列表视图,它运行正常,但我的用例是将第5个或第X个元素固定在屏幕顶部,而其他元素会滚动。

英文:

I am new in android jetpack compose i created a list view using lazyColumn that is working fine
but my use case is to pin the 5th or Xth element to the top of the screen while other elements will scroll.

答案1

得分: 1

你可以使用 stickyheader 来实现这个功能。

LazyColumn() {
     stickyheader {
         //你的第 x 个元素
     }
     //其余的项目
}

它将始终保持在惰性列的顶部,同时其他项目将能够在其下滚动。

英文:

You can use stickyheader for this.

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

It will always stick to the top of the lazy column meanwhile rest of the items will be able to scroll underneath it.

huangapple
  • 本文由 发表于 2023年6月22日 02:29:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76526169.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定