Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parallax Effect in ViewPager #5

Open
DonLiangGit opened this issue Oct 13, 2014 · 1 comment
Open

Parallax Effect in ViewPager #5

DonLiangGit opened this issue Oct 13, 2014 · 1 comment

Comments

@DonLiangGit
Copy link
Owner

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
Copy link
Owner Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant