package com.lsjwzh.widget.recyclerviewpagerdeomo;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager;

public class VerticalPagerActivity extends Activity {
    protected RecyclerViewPager mRecyclerView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.demo_vertical_viewpager);
        initViewPager();
    }

    protected void initViewPager() {
        mRecyclerView = (RecyclerViewPager) findViewById(R.id.viewpager);

        LinearLayoutManager layout = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL,
                false);
        mRecyclerView.setTriggerOffset(0.15f);
        mRecyclerView.setFlingFactor(0.25f);
        mRecyclerView.setLayoutManager(layout);
        mRecyclerView.setAdapter(new LayoutAdapter(this, mRecyclerView));
        mRecyclerView.setHasFixedSize(true);
        mRecyclerView.setLongClickable(true);

        mRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int scrollState) {

            }

            @Override
            public void onScrolled(RecyclerView recyclerView, int i, int i2) {
//                mPositionText.setText("First: " + mRecyclerViewPager.getFirstVisiblePosition());
                int childCount = mRecyclerView.getChildCount();
                int width = mRecyclerView.getChildAt(0).getWidth();
                int padding = (mRecyclerView.getWidth() - width) / 2;

                for (int j = 0; j < childCount; j++) {
                    View v = recyclerView.getChildAt(j);
                    //往左 从 padding 到 -(v.getWidth()-padding) 的过程中，由大到小
                    float rate = 0;
                    if (v.getLeft() <= padding) {
                        if (v.getLeft() >= padding - v.getWidth()) {
                            rate = (padding - v.getLeft()) * 1f / v.getWidth();
                        } else {
                            rate = 1;
                        }
                        v.setScaleY(1 - rate * 0.1f);
                    } else {
                        //往右 从 padding 到 recyclerView.getWidth()-padding 的过程中，由大到小
                        if (v.getLeft() <= recyclerView.getWidth() - padding) {
                            rate = (recyclerView.getWidth() - padding - v.getLeft()) * 1f / v.getWidth();
                        }
                        v.setScaleY(0.9f + rate * 0.1f);
                    }
                }
            }
        });

        mRecyclerView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
            @Override
            public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
                if (mRecyclerView.getChildCount() < 3) {
                    if (mRecyclerView.getChildAt(1) != null) {
                        View v1 = mRecyclerView.getChildAt(1);
                        v1.setScaleY(0.9f);
                    }
                } else {
                    if (mRecyclerView.getChildAt(0) != null) {
                        View v0 = mRecyclerView.getChildAt(0);
                        v0.setScaleY(0.9f);
                    }
                    if (mRecyclerView.getChildAt(2) != null) {
                        View v2 = mRecyclerView.getChildAt(2);
                        v2.setScaleY(0.9f);
                    }
                }

            }
        });
    }
}

@@ -1992,28 +1992,27 @@
    if (v.get
-Left
+Top
 () %3C= paddin
@@ -2049,20 +2049,19 @@
 f (v.get
-Left
+Top
 () %3E= pa
@@ -2073,21 +2073,22 @@
  - v.get
-Width
+Height
 ()) %7B%0A  
@@ -2128,36 +2128,35 @@
 (padding - v.get
-Left
+Top
 ()) * 1f / v.get
@@ -2147,37 +2147,38 @@
 ()) * 1f / v.get
-Width
+Height
 ();%0A            
@@ -2254,32 +2254,86 @@
               %7D%0A
+                        v.setScaleX(1 - rate * 0.1f);%0A
                 
@@ -2452,29 +2452,30 @@
 clerView.get
-Width
+Height
 ()-padding %E7%9A%84
@@ -2516,20 +2516,19 @@
 f (v.get
-Left
+Top
 () %3C= re
@@ -2533,37 +2533,38 @@
 recyclerView.get
-Width
+Height
 () - padding) %7B%0A
@@ -2611,29 +2611,30 @@
 clerView.get
-Width
+Height
 () - padding
@@ -2641,20 +2641,19 @@
  - v.get
-Left
+Top
 ()) * 1f
@@ -2656,29 +2656,30 @@
 * 1f / v.get
-Width
+Height
 ();%0A        
@@ -2688,32 +2688,89 @@
               %7D%0A
+                        v.setScaleX(0.9f + rate * 0.1f);%0A
                 

Update VerticalPagerActivity Demo for scaling