美文网首页安卓开发博客Android_MaterialDesign
MaterialDesign系列文章(四)RecealAnima

MaterialDesign系列文章(四)RecealAnima

作者: 笔墨Android | 来源:发表于2017-11-06 23:36 被阅读38次

不怕跌倒,所以飞翔

RevealAnimator动画效果

首先这个动画是在5.0以上的版本才能使用的

  • view 作用的View
  • centerX 动画开始的中心点X
  • centerY 动画开始的中心点Y
  • startRadius 动画开始半径
  • endRadius 动画结束半径
    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();  
    }  
});  

这一系列文章的地址,希望对大家有帮助

项目地址

相关文章

网友评论

    本文标题:MaterialDesign系列文章(四)RecealAnima

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