Skip to content

Instantly share code, notes, and snippets.

@kyze8439690
Last active August 27, 2016 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyze8439690/f4a216b2765b59723d12 to your computer and use it in GitHub Desktop.
Save kyze8439690/f4a216b2765b59723d12 to your computer and use it in GitHub Desktop.
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