I need to make this animation in a vertical ViewPager
:
https://www.youtube.com/watch?v=wuE-4jjnp3g
this what i tried so far :
viewPager = (VerticalViewPager) rootView.findViewById(R.id.viewpager);
viewPager.setPageTransformer(false, new ViewPager.PageTransformer() {
@Override
public void transformPage(View page, float position) {
if (position >= 0.5F && position <= 1F) {
float progressStart = 0.5f;
float progressEnd = 1f;
float progressDelta = progressEnd - progressStart;
float progress = (position - progressStart)/progressDelta;
if(progress>1)progress=1;
if(progress<0)progress=0;
float endValue = 1f;
float startValue = 0.8f;
float delta = endValue - startValue;
progress = 1-progress;
float currentScale = startValue + delta*progress;
ViewCompat.setPivotY(page,0);
ViewCompat.setScaleX(page, currentScale);
ViewCompat.setScaleY(page, 0.9F);
ViewCompat.setTranslationY(page, 0);
} else {
ViewCompat.setScaleX(page, 1.0F); //- width
ViewCompat.setScaleY(page, 0.9F); //- height
}
}
});
this is the result:
https://www.youtube.com/watch?v=G9W2lCKP-_s
I'm using a Copy of original ViewPager with vertical orientation, to see the code : https://github.com/Devlight/InfiniteCycleViewPager/blob/master/infinitecycleviewpager/src/main/java/com/gigamole/infinitecycleviewpager/VerticalViewPager.java
Obviously its not even close, i need to have a preview of the next page and make the two pages closer .
Please help
Thank you.
i need to have a preview of the next page
you have to add
to your
<com.gigamole.infinitecycleviewpager.VerticalViewPager
in layoutin your java code put it, of course you should tweak
startTranslation
andstartValue
andpaddingBottom
in your layout