May 24 2014
Android: Circular ViewPager
Recently I was building an Android Application and needed a circular ViewPager. That is a ViewPager that will automatically move to the first page when you swipe the last. Apparently there is no Native Support for this, neither could I find any good implementation online.
So here is a simple but effective way to do this.
The idea is basically to apply the functionality to the PagerAdapter you will insert in the ViewPager. What you do is create a huge set of Pages (lets say 10000) and set the current page in the middle.
So here it is:
/** * Created by Chris Georgoulis on 8/3/2014. */ public class ImageAdapter extends PagerAdapter { public static final int PAGER_PAGES = 10000; public static final int PAGER_PAGES_MIDDLE = PAGER_PAGES / 2; private List drawables; public ImageAdapter(List drawables) { this.drawables = drawables; }
Recent Comments