package cn.bingoogolapple.bgabanner.transformer; import android.support.v4.view.ViewCompat; import android.view.View; /** * 作者:王浩 邮件:bingoogolapple@gmail.com * 创建时间:15/6/19 17:39 * 描述: */ public class CubePageTransformer extends BGAPageTransformer { private float mMaxRotation = 90.0f; public CubePageTransformer() { } public CubePageTransformer(float maxRotation) { setMaxRotation(maxRotation); } @Override public void handleInvisiblePage(View view, float position) { ViewCompat.setPivotX(view, view.getMeasuredWidth()); ViewCompat.setPivotY(view, view.getMeasuredHeight() * 0.5f); ViewCompat.setRotationY(view, 0); } @Override public void handleLeftPage(View view, float position) { ViewCompat.setPivotX(view, view.getMeasuredWidth()); ViewCompat.setPivotY(view, view.getMeasuredHeight() * 0.5f); ViewCompat.setRotationY(view, mMaxRotation * position); } @Override public void handleRightPage(View view, float position) { ViewCompat.setPivotX(view, 0); ViewCompat.setPivotY(view, view.getMeasuredHeight() * 0.5f); ViewCompat.setRotationY(view, mMaxRotation * position); } public void setMaxRotation(float maxRotation) { if (maxRotation >= 0.0f && maxRotation <= 90.0f) { mMaxRotation = maxRotation; } } }