Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement 'Snap to center' feature for lists in Jetpack Compose?

In EpoxyRecyclerView with Horizontal LinearLayout there is a Snap to center feature which works like, If i scroll the list with good speed, it keeps on scrolling until it slows down and rests with an item at center. And if I scroll slowly and lift up the finger, then the next item spans/moves to center of screen. One thing you have to understand that, this is not a Pager. Pager automatically snaps the next item only. But I cannot scroll like a free rolling...

You can see this gif as an example

enter image description here

So, I'm looking for such snapping feature in Jetpack Compose. Is this possible yet? If yes, how to achieve this?

like image 858
Syed Zeeshan Avatar asked Jan 24 '26 01:01

Syed Zeeshan


1 Answers

If you use Compose 1.3 you can check the SnapFlingBehavior here

like image 166
AouledIssa Avatar answered Jan 26 '26 15:01

AouledIssa