Circular Reveal 揭露效果

<p>

ViewAnimationUtils.createCircularReveal()

  • 方法参数
/**
 * @param view        执行动画的view
 * @param centerX     动画圆中心的X坐标
 * @param centerY     动画圆中心的Y坐标
 * @param startRadius 动画圆的起始半径
 * @param endRadius   动画圆的结束半径
 */
public static Animator createCircularReveal(View view, int centerX, int centerY, float startRadius, float endRadius) {
    throw new RuntimeException("Stub!");
}
  • 使用方法
@Override
public void onClick(View view) {
    // 动画圆中心的X坐标
    int centerX = view.getWidth() / 2;
    // 动画圆中心的Y坐标
    int centerY = view.getHeight() / 2;
    // 动画圆的起始半径:从圆心开始执行动画
    float startRadius = 0;
    // 动画圆的结束半径:计算长宽的斜边长
    float endRadius = (float) Math.hypot((double) (view.getWidth() / 2), (double) (view.getHeight() / 2));
    // 定义揭露动画
    Animator animator = ViewAnimationUtils.createCircularReveal(
            view, centerX, centerY, startRadius, endRadius
    );
    // 设置动画监听:可根据需求在动画开始或结束时做相应操作
    animator.addListener(new MyAnimatorListener());
    // 设置动画持续时间
    animator.setDuration(1000);
    // 开始执行动画
    animator.start();
}
// 动画监听
private class MyAnimatorListener implements Animator.AnimatorListener {
    @Override
    public void onAnimationStart(Animator animator) {
    }
    @Override
    public void onAnimationEnd(Animator animator) {
    }
    @Override
    public void onAnimationCancel(Animator animator) {
    }
    @Override
    public void onAnimationRepeat(Animator animator) {
    }
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容