At first I thought it's easy, someone must have implemented it already, but after searching for it on Google, I got no luck, nobody has done and shared it on the Net, so I decided to make it myself.
I read some posts like:
So I implemented it as you can see in below video:
For more information, you guys can get the source code here: https://github.com/mrleolink/SimpleInfiniteCarousel. I tried to comment as much as possible in source code, so I hope you understand my idea.
I read some posts like:
So I implemented it as you can see in below video:
The main idea is:
- Use ViewPager as the main view with pages are Fragment, then use ViewPager.setPageMargin(int) to set margin as a negative number, so the next and previous pages of the selected page will be showed up.
- Override the layout which is the root view of Fragments to create scale animation.
- Make a little hack in FragmentPagerAdapter so we can fling infinitely to both directions of the ViewPager.
By the way, I don't think it's the best solution to implement the carousel pattern, so if you have any idea or there's something you don't understand about what I code, just drop me a line :)