英文:
How to make a customized scroll in LazyRow Jetpack Compose
问题
我正在使用Jetpack Compose制作Trello应用程序的克隆版。其中有一个屏幕,显示了面板中的所有列表,并以一行的方式展示,我已经使用lazyRow来实现这个功能。
在原始的Trello应用程序中,当滚动列表时,我注意到的一个区别是,下一个项目会在屏幕的正中间准确停止,即使我们以更快的速度滚动,也不会跳过任何项目。
然而,在我的克隆应用程序中的LazyRow中,滚动行为只取决于我们滚动的速度。
我想知道我们是否可以在LazyRow中实现类似Trello的滚动功能。
英文:
I am making a trello application clone in jetpack compose. In which there is a screen where all the lists in the board are displayed in a row , I have used lazyRow to implement that.
One difference I saw when scrolling the lists in the original trello app was that while scrolling the next item would stop exactly at the middle of the screen and it also doesn't skip any item even if we scroll with more speed.
Whereas in the LazyRow in my clone application the scroll behavoiur just depends on the power of our scroll.
I wanted to know if we could implement the trello like scrolling functionality in LazyRow.
答案1
得分: 1
Yes, you can use SnapFlingBehavior
for that. You can have a look at the HorizontalPager
implementation to see how it is used - it is a wrapper for LazyRow
which is using SnapFlingBehavior
. Depending on what exactly you need, you might be even able to simply replace your LazyRow
with HorizontalPager
and use different pageSize
than the default PageSize.Fill
.
英文:
Yes, you can use SnapFlingBehavior
for that. You can have a look at the HorizontalPager
implementation to see how it is used - it is a wrapper for LazyRow
which is using SnapFlingBehavior
. Depending on what exactly you need, you might be even able to simply replace your LazyRow
with HorizontalPager
and use different pageSize
than the default PageSize.Fill
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论