package com.test.banner;
import android.support.v4.view.ViewPager;
import android.view.View;
/**
* 自定义动画效果
* 调用 banner.setPageTransformer()方法设置
*/
public class GallyPageTransformer implements ViewPager.PageTransformer {
private static final float min_scale = 0.85f;
@Override
public void transformPage(View page, float position) {
float scaleFactor = Math.max(min_scale, 1 - Math.abs(position));
float rotate = 20 * Math.abs(position);
if (position < -1) {
} else if (position < 0) {
page.setScaleX(scaleFactor);
page.setScaleY(scaleFactor);
page.setRotationY(rotate);
} else if (position >= 0 && position < 1) {
page.setScaleX(scaleFactor);
page.setScaleY(scaleFactor);
page.setRotationY(-rotate);
} else if (position >= 1) {
page.setScaleX(scaleFactor);
page.setScaleY(scaleFactor);
page.setRotationY(-rotate);
}
}
}