Search code examples
androidlayouthorizontalscrollview

How to stop scrolling as half item can be visible in HorizontalScrollView


Can you plz share any suggestion or library to achieve below,

enter image description here

e.g. If you see in Google Play Store, when you scroll HorizontalScrollView, your scrolling will stop as half of the next item user can able to see. App forcefully stops scroll like this so the user gets to know, there are more items available.

I do not have any code to share. I just want your hints/libs.

Thank you!


Solution

  • You can achieve this by using Snaphelper in RecycleView its available in support libraries You can attached SnapHelper like this

    SnapHelper startSnapHelper = new StartSnapHelper();
    startSnapHelper.attachToRecyclerView(yourRecyclerView);