content: package com.allure.lbanners.transformer;
  
  import android.view.View;
  
  import com.nineoldandroids.view.ViewHelper;
  
  /**
   * Created by lm on 2016/7/8.
   */
  public class ZoomPageTransformer extends LMPageTransformer {
      private float mMinScale = 0.85f;
      private float mMinAlpha = 0.65f;
  
      public ZoomPageTransformer() {
      }
  
      public ZoomPageTransformer(float minAlpha, float minScale) {
          setMinAlpha(minAlpha);
          setMinScale(minScale);
      }
  
      @Override
      public void scrollInvisible(View view, float position) {
          ViewHelper.setAlpha(view, 0);
      }
  
      @Override
      public void scrollLeft(View view, float position) {
          float scale = Math.max(mMinScale, 1 + position);
          float vertMargin = view.getHeight() * (1 - scale) / 2;
          float horzMargin = view.getWidth() * (1 - scale) / 2;
          ViewHelper.setTranslationX(view, horzMargin - vertMargin / 2);
          ViewHelper.setScaleX(view, scale);
          ViewHelper.setScaleY(view, scale);
          ViewHelper.setAlpha(view, mMinAlpha + (scale - mMinScale) / (1 - mMinScale) * (1 - mMinAlpha));
      }
  
      @Override
      public void scrollRight(View view, float position) {
          float scale = Math.max(mMinScale, 1 - position);
          float vertMargin = view.getHeight() * (1 - scale) / 2;
          float horzMargin = view.getWidth() * (1 - scale) / 2;
          ViewHelper.setTranslationX(view, -horzMargin + vertMargin / 2);
          ViewHelper.setScaleX(view, scale);
          ViewHelper.setScaleY(view, scale);
          ViewHelper.setAlpha(view, mMinAlpha + (scale - mMinScale) / (1 - mMinScale) * (1 - mMinAlpha));
      }
  
      public void setMinAlpha(float minAlpha) {
          if (minAlpha >= 0.6f && minAlpha <= 1.0f) {
              mMinAlpha = minAlpha;
          }
      }
  
      public void setMinScale(float minScale) {
          if (minScale >= 0.6f && minScale <= 1.0f) {
              mMinScale = minScale;
          }
      }
  
  
  }