Forked from anonymous/gist:d532d41fa01c02a65782
Created
December 15, 2015 11:46
Revisions
-
There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ public class ParallaxPageTransformer implements ViewPager.PageTransformer { public void transformPage(View view, float position) { int pageWidth = view.getWidth(); if (position < -1) { // [-Infinity,-1) // This page is way off-screen to the left. view.setAlpha(1); } else if (position <= 1) { // [-1,1] dummyImageView.setTranslationX(-position * (pageWidth / 2)); //Half the normal speed } else { // (1,+Infinity] // This page is way off-screen to the right. view.setAlpha(1); } } }