Created
August 15, 2014 13:31
-
-
Save feromakovi/1654f6e2436a70fefd61 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FilterPageTransformer implements ViewPager.PageTransformer { | |
public void transformPage(View view, float position) { | |
ImageView im = (ImageView) view; | |
int pageWidth = view.getWidth(); | |
if (position < -1) { // [-Infinity,-1) | |
// This page is way off-screen to the left. | |
im.setPadding(pageWidth, 0, 0, 0); | |
} else if (position <= 0) { // [-1,0] | |
// Use the default slide transition when moving to the left page | |
im.setPadding(-1 * Math.round(position * pageWidth) , 0, 0, 0); | |
} else if (position <= 1) { // (0,1] | |
log.d("position 0 1: " + position); | |
// Fade the page out. | |
// Counteract the default slide transition | |
im.setTranslationX(pageWidth * -position); | |
im.setPadding(0, 0, Math.round((1 - position) * pageWidth), 0); | |
} else { // (1,+Infinity] | |
// This page is way off-screen to the right. | |
//view.setAlpha(1); | |
im.setPadding(0, 0, pageWidth, 0); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment