admin管理员组文章数量:1418093
I am building an app fully compose and used LazyColum + StickyHeader to display the elements I need to. However, the stickyHeader is not moving at the same pace. It stays on screen untli the next header arrives. I put a link to the video below:
I used the code below to do it:
Column(modifier
.padding(horizontal = 36.dp)) {
LazyColumn(modifier
.padding(top = 36.dp)) {
list.forEach { category ->
stickyHeader {
CategoryHeader(title = category.type)
}
items(category.transactions) { transaction ->
ItemRow(navController, transaction)
}
}
}
}
Any idea how to make sure that the header is scrolling when the items are scrolling >
I am building an app fully compose and used LazyColum + StickyHeader to display the elements I need to. However, the stickyHeader is not moving at the same pace. It stays on screen untli the next header arrives. I put a link to the video below:
https://photos.app.goo.gl/LbWTrSwfRQVze9ce7
I used the code below to do it:
Column(modifier
.padding(horizontal = 36.dp)) {
LazyColumn(modifier
.padding(top = 36.dp)) {
list.forEach { category ->
stickyHeader {
CategoryHeader(title = category.type)
}
items(category.transactions) { transaction ->
ItemRow(navController, transaction)
}
}
}
}
Any idea how to make sure that the header is scrolling when the items are scrolling >
Share Improve this question asked Jan 29 at 19:14 SebSeb 3,2315 gold badges39 silver badges87 bronze badges 2 |2 Answers
Reset to default 0The sticky header behavior is working as expected. Try putting the header inside the items
function and try again.
items(...) {
Column {
CategoryHeader(...)
ItemRow(...)
}
}
As pointed out by @ianhanniballake, you can use the item()
extension function of LazyListScope
if you want to add one specific Compsable to the LazyColumn
:
LazyColumn(
modifier.padding(top = 36.dp)
) {
list.forEach { category ->
item {
CategoryHeader(title = category.type)
}
items(category.transactions) { transaction ->
ItemRow(navController, transaction)
}
}
}
The stickyHeader
is meant to stick to the top of the LazyColumn until the next stickyHeader
appears.
本文标签: androidStickyHeader not following the scrolling in LazyColumnStack Overflow
版权声明:本文标题:android - StickyHeader not following the scrolling in LazyColumn - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745282166a2651484.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
stickyHeader
and not just usingitem
? – ianhanniballake Commented Jan 29 at 19:24