Search code examples
androidlistviewscrolladapter

How to set a final scroll's position in listView?


Maybe someone faced such a problem: I have adapter class, customView class. Everything works normal. But: When I scroll listView, It's possible to stop the scroll anywhere in the middle. But I expected: a final scroll's position (when soon as user's finger is up and inertia-movement is completed) should always be like on my screenshot(image1) and never like this(image2). image1 image2


Solution

  • I hope I understood your question right.

    To achieve this in ListView Android ListView - stop scrolling at 'whole' row position

    For RecyclerView You can achieve this by using SnapHelper

    LinearSnapHelper().attachToRecyclerView(recyclerView)