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) {
    }
}
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容