New received the task is to make a can quickly slide several pages of banner control, before the use of viewPager implementation, tried to change the feeling based on viewPager is not very good implementation, behind the group of friends recommended the use of RecycleView, probably achieved.

First of all, thanks to RecyclerViewCardGallery- Android uses RecyclerView to achieve Gallery effect

Github.com/huazhiyuan2…

The implementation effect is as follows:

1. Deficiencies of the original library

1. Does not support infinite loop sliding 2. Does not provide a fast jump to a location function

2. Core code to solve the above deficiencies

  1. The changes needed to support unlimited sliding first the Adapter needs to be changed

    Then you need to get the position corrected via the LinearSnapHelper and the position mLastPos after the slide stops

I got mLastPos mainly to modify the card scaling when it supports infinite sliding (the original scaling code is invalid because of the loop)

2 Added a function to quickly jump to a certain location

Short distance rolling sliding to a certain location or use recycleView. Of course smoothScrolltoPosition, it will help you to scroll to a location and centered.

3. Code download location

Making address github.com/zjw-swun/Re… If you like, give it to Star