2

I have a Recyclerview containing images, each image filling the view completely. I want the user to be able to scroll them one at a time, so it does not scroll more than one element, and it stops at the beginning of each element.

I tried adding a scroll listener, but I am unable to lock the scrolling.

Do you know how to achieve this behavior?

Jserra
  • 159
  • 1
  • 9
  • why not have a simple Imageview and set GestureListener to it when you detect a scroll simply replace The ImagevIew with new Image – Sanjeev Jul 21 '15 at 15:37
  • Duplicate question. Please refer this [link](http://stackoverflow.com/a/41988804/7182978). – Kshitij Jain Feb 11 '17 at 18:33

2 Answers2

2

As you can see here the best solution I've could find is:

RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
LinearLayoutManager layoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
SnapHelper snapHelper = new PagerSnapHelper();
recyclerView.setLayoutManager(layoutManager);
snapHelper.attachToRecyclerView(mRecyclerView);

Setting the orientation vertical it should work

Mattia Ferigutti
  • 2,608
  • 1
  • 18
  • 22
1

Don't use a RecyclerView. Use a ViewPager that has a vertical direction. http://developer.android.com/reference/android/support/v4/view/ViewPager.html

se_bastiaan
  • 1,716
  • 14
  • 19
  • Actually I used a [library](https://github.com/lsjwzh/RecyclerViewPager) called RecyclerViewPager from lsjwzh, works really well. – Jserra Jul 22 '15 at 13:52