Parallax Effect in ViewPager
Opened this issue · 1 comments
DonLiangGit commented
Fragment Pager Parallax Solution:
mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@OverRide
public void onPageScrolled(int position, float percent, int offset) {
int totalPages = 4;
float Percentage = ((position+percent)_100 / totalPages);
mImageDrawable.setLevel((int)(400_Percentage));
}
}
The key point is that: set a clipdrawable then set its level based on the percentage of page scrolling.
DonLiangGit commented
Background Parallax Solution:
Define a ScrollView in the background layer, the viewpager is defined in another layer which is inflated by Layoutinflater. (Not accurate) / Alternative method: make a ImageView set its scale type then make the imageview translationY direction.