-
-
Save cristiana214/f64429b7244800d788ea 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
/* | |
Usage: | |
viewPager.setPageTransformer(true, new CardTransformer(0.7f)); | |
*/ | |
public class CardTransformer implements PageTransformer { | |
private final float scalingStart; | |
public CardTransformer(float scalingStart) { | |
super(); | |
this.scalingStart = 1 - scalingStart; | |
} | |
@Override | |
public void transformPage(View page, float position) { | |
if (position >= 0) { | |
final int w = page.getWidth(); | |
float scaleFactor = 1 - scalingStart * position; | |
page.setAlpha(1 - position); | |
page.setScaleX(scaleFactor); | |
page.setScaleY(scaleFactor); | |
page.setTranslationX(w * (1 - position) - w); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment