背景到前景 BackgroundToForegroundTran

2020-05-14  本文已影响0人  菜鸟何时起飞
BackgrounToFore.gif
public class BackgroundToForegroundTransformer extends ABaseTransformer {

    @Override
    protected void onTransform(View view, float position) {
        final float height = view.getHeight();
        final float width = view.getWidth();
        final float scale = min(position < 0 ? 1f : Math.abs(1f - position), 0.5f);

        view.setScaleX(scale);
        view.setScaleY(scale);
        view.setPivotX(width * 0.5f);
        view.setPivotY(height * 0.5f);
        view.setTranslationX(position < 0 ? width * position : -width * position * 0.25f);
    }

}
上一篇 下一篇

猜你喜欢

热点阅读