RevealAnimator動(dòng)畫效果
首先這個(gè)動(dòng)畫是在5.0以上的版本才能使用的
- view 作用的View
- centerX 動(dòng)畫開始的中心點(diǎn)X
- centerY 動(dòng)畫開始的中心點(diǎn)Y
- startRadius 動(dòng)畫開始半徑
- endRadius 動(dòng)畫結(jié)束半徑
public static Animator createCircularReveal(View view,
int centerX, int centerY, float startRadius, float endRadius) {
return new RevealAnimator(view, centerX, centerY, startRadius, endRadius);
}
[圖片上傳失敗...(image-95eb0a-1510292999859)]
final View oval = this.findViewById(R.id.oval);
oval.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Animator animator = ViewAnimationUtils.createCircularReveal(
oval,
oval.getWidth()/2,
oval.getHeight()/2,
oval.getWidth(),
0);
animator.setInterpolator(new AccelerateDecelerateInterpolator());
animator.setDuration(2000);
animator.start();
}
});
final View rect = this.findViewById(R.id.rect);
rect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Animator animator = ViewAnimationUtils.createCircularReveal(rect, 0, 0, 0, (float) Math.hypot(rect.getWidth(), rect.getHeight()));
animator.setInterpolator(new AccelerateInterpolator());
animator.setDuration(2000);
animator.start();
}
});