Q:

Android ViewPager ZoomOut animation

I have a ViewPager that look like this:

I need the previews on the sides to ZoomOut when you swipe and only maintain the size of the center view, something like this:

I already tried some examples with ViewPager.PageTransformer() but those examples are always with a fade animation(That I don't need) and not showing previews(Wich I need).

A:

    final int paddingPx = 300;
    final float MIN_SCALE = 0.8f;
    final float MAX_SCALE = 1f;

    viewPager.setClipToPadding(false);
    viewPager.setPadding(paddingPx, 0, paddingPx, 0);
    viewPager.setPageTransformer(false, transformer);

This makes pages smaller than viewpager width:
 
Here is my Transformer:
    PageTransformer transformer = new PageTransformer() {
        @Override
        public void transformPage(View page, float position) {
            float pagerWidthPx = ((ViewPager) page.getParent()).getWidth();
            float pageWidthPx = pagerWidthPx - 2 * paddingPx;

            float maxVisiblePages = pagerWidthPx / pageWidthPx;
            float center = maxVisiblePages / 2f;

            float scale;
            if (position + 0.5f < center - 0.5f || position > center) {
                scale = MIN_SCALE;
            } else {
                float coef;
                if (position + 0.5f < center) {
                    coef = (position + 1 - center) / 0.5f;
                } else {
                    coef = (center - position) / 0.5f;
                }
                scale = coef * (MAX_SCALE - MIN_SCALE) + MIN_SCALE;
            }
            page.setScaleX(scale);
            page.setScaleY(scale);
        }
    };

The difficult thing about this is position parameter of transformPage method. When pages are fill viewpagers width this param changes from 0 to 1. But when pages are smaller this param is tricky.
position is value of left side of the view. Page width equals to 1. position equals to 0 when pages left side is on the left side of viewpager.  So position can be more than 1, depends on page width. 

First you need to find viewpagers center (relatively to position parameter). Then scale down page if page moves to left or to rigth from center. In my implementation I scale down  view on half page distance from center.
Here is result:

Page width can be controlled via padding. 
Extra margin between pages can be added throught viewPager.setPageMargin(value) method.

