失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > android 圆形收缩动画 Android官方圆形揭露动画

android 圆形收缩动画 Android官方圆形揭露动画

时间:2024-03-20 13:28:26

相关推荐

android 圆形收缩动画 Android官方圆形揭露动画

圆形揭露动画

具体使用如下

主要使用的是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

}

}

如果觉得《android 圆形收缩动画 Android官方圆形揭露动画》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。