Android官方圆形揭露动画

圆形揭露动画

今天看官方的动画效果无意发现了这个动画,可能是之前没怎么关注吧使用也很简单,其实就是一个圆形缩小或者变大的动画.官方连接如下:
https://developer.android.com/training/animation/reveal-or-hide-view
中文地址如下:
https://developer.android.google.cn/training/animation/reveal-or-hide-view

具体使用如下

主要使用的是ViewAnimationUtils.createCircularReveal(view, cx, cy, initialRadius, 0F)这个方法,其中后面两个参数用来控制变大还是缩小

fun animator(view: View) {
        // Check if the runtime version is at least Lollipop
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            // get the center for the clipping circle
            val cx = view.width / 2
            val cy = view.height / 2
            // get the initial radius for the clipping circle
            val initialRadius = Math.hypot(cx.toDouble(), cy.toDouble()).toFloat()
            // create the animation (the final radius is zero)
            val anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, initialRadius, 0F)

            // make the view invisible when the animation is done
            anim.addListener(object : AnimatorListenerAdapter() {

                override fun onAnimationEnd(animation: Animator) {
                    super.onAnimationEnd(animation)
                    view.visibility = View.INVISIBLE
                }
            })
            // start the animation
            anim.start()
        } else {
            // set the view to visible without a circular reveal animation below Lollipop
            view.visibility = View.INVISIBLE
        }
    }
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1 背景 不能只分析源码呀,分析的同时也要整理归纳基础知识,刚好有人微博私信让全面说说Android的动画,所以今...
    未聞椛洺阅读 2,755评论 0 10
  • 【Android 动画】 动画分类补间动画(Tween动画)帧动画(Frame 动画)属性动画(Property ...
    Rtia阅读 6,247评论 1 38
  • 转载一篇高质量博文,原地址请戳这里转载下来方便今后查看。1 背景不能只分析源码呀,分析的同时也要整理归纳基础知识,...
    Elder阅读 1,954评论 0 24
  • 1 背景 不能只分析源码呀,分析的同时也要整理归纳基础知识,刚好有人微博私信让全面说说Android的动画,所以今...
    lisx_阅读 974评论 0 0
  • 自己总结的Android开源项目及库。 github排名https://github.com/trending,g...
    passiontim阅读 2,588评论 1 26