Last active
August 27, 2016 08:50
-
-
Save kyze8439690/f4a216b2765b59723d12 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
import android.support.v4.view.ViewPager; | |
import android.view.View; | |
public class StackPageTransformer implements ViewPager.PageTransformer { | |
@TargetApi(Build.VERSION_CODES.HONEYCOMB) | |
public void transformPage(View page, float position) { | |
final float alpha; | |
final float translationX; | |
if (position > 0 && position < 1) { | |
// moving to the right | |
alpha = (1 - position); | |
translationX = 0.8f * page.getWidth() * -position; | |
} else { | |
// use default for all other cases | |
alpha = 1; | |
translationX = 0; | |
} | |
page.setAlpha(alpha); | |
page.setTranslationX(translationX); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment