Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.