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).
Asked
Active
Viewed 83 times
0
1 Answers
0
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)

shb
- 5,957
- 2
- 15
- 32
-
#shb, hello. Thank you for advice. After studying the information that you advised I came to a decision: (maybe someone will be useful): – Julia Aug 20 '20 at 08:56
-
#shb, hello. Thank you for your advice. After studying the information what you advised, it seems I found solving problem for me:(maybe it will be useful for someone): – Julia Aug 20 '20 at 09:07
-
View childView = view.getChildAt(0); Rect rect = new Rect(0, 0, childView.getWidth(), childView.getHeight()); double height = childView.getHeight(); view.getChildVisibleRect(childView, rect, null); if (Math.abs(rect.height()) < height / 2.0) { view.smoothScrollToPosition(view.getLastVisiblePosition()); } else { view.smoothScrollToPosition(view.getFirstVisiblePosition()); – Julia Aug 20 '20 at 09:13