美文网首页
背景到前景 BackgroundToForegroundTran

背景到前景 BackgroundToForegroundTran

作者: 菜鸟何时起飞 | 来源:发表于2020-05-14 14:06 被阅读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);
    }

}

相关文章

网友评论

      本文标题:背景到前景 BackgroundToForegroundTran

      本文链接:https://www.haomeiwen.com/subject/qbktohtx.html