ParallaxViewPager
a simple ViewPager with parallax effect.
The first gif foreground speed = 2*background speed witch is speedRatio = 0.5 |
the second gifforeground speed = background speed witch is speedRatio = 1 |
---|---|
![]() |
![]() |
Add to your project
Gradle
- Add it in your root build.gradle at the end of repositories:
- Add the dependency
Maven
- Add the JitPack repository to your build file
- Add the dependency
Usage
- Just like normal ViewPager
set background image just like ViewPager.
you can set in xml
android:background="@drawable/background"
or in code
Configuration
- you can set speed ratio in xml
- also set in code
Note: the default ratio is 0.5f
Restrictions
- The background image's width should larger than height.
- The background image's width should larger than ViewPager's width.
- You can't set pager with padding.
- If the ratio that user set is not proper, it will be recalculate and reset.