1. Download and import library
- Import project from "lib" folder after extract, it will become "MainActivity" project in Eclipse.
- Start a new android project and make reference to this library project:
2. Make ViewPager "components"
Nothing special, we create a ViewPagerAdapter extends FragmentStatePagerAdapter or FragmentPagerAdapter. In this adapter, like the library document said, in order to get the animations to work correctly for more than 3 Views, we'll have to add the following to the instantiateItem() method of our PagerAdapter.
Source code for adapter:
Create a simple Fragment for each ViewPager page:
And it's layout:
3. Create Activity to run
In this activity, we will change ViewPager sliding style based on selecting item in a spinner. Layout (xml) for it:
And programatically code:
4. Runing application
Our result like this:
5. References
- Official library page in Github: https://github.com/jfeinstein10/JazzyViewPager