Animation in a vertical ViewPager

I need to make this animation in a vertical ViewPager :

enter image description here

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:

enter image description here

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 .

enter image description here

Please help

Thank you.

Answer

i need to have a preview of the next page

you have to add

        android:paddingBottom="200dp"
        android:clipToPadding="false"

to your <com.gigamole.infinitecycleviewpager.VerticalViewPagerin layout

in your java code put it, of course you should tweak startTranslation and startValue and paddingBottom in your layout

        viewPager.setPageTransformer(true, new ViewPager.PageTransformer() {
        @Override
        public void transformPage(View page, float position) {
            ViewCompat.setPivotY(page,0);
            ViewCompat.setPivotX(page,page.getWidth()/2);
            float endTranslation = 0f;
            float startTranslation  = -400f;
            float deltaTranslation = endTranslation - startTranslation;

            float endScale = 1f;
            float startScale = 0.8f;
            float deltaScale = endScale - startScale;
            
            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;

            progress = 1-progress;
            
            float currentScale = startScale + deltaScale*progress;
            ViewCompat.setScaleX(page, currentScale);
            ViewCompat.setScaleY(page, currentScale);

            float currentTranslation = startTranslation + deltaTranslation*progress;
            ViewCompat.setTranslationY(page, currentTranslation);
        }