Last active
April 9, 2016 16:32
-
-
Save pyk/b7ab4dfa4f0f7d2e94f3 to your computer and use it in GitHub Desktop.
ViewPager.PageTransformer custom animation
This file contains hidden or 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
in this code what we can define mBluler and mDimp
@OverRide
public void transformPage(View view, float position) {
int pageWidth = view.getWidth();
}