直接上代码:
fun fadeOut(view: View, delayTime: Long) {
if (view?.visibility != View.VISIBLE) return
// Since the button is still clickable before fade-out animation
// ends, we disable the button first to block click.
view?.isEnabled = false
val animation: Animation = AlphaAnimation(1f, 0f)
animation?.duration = delayTime
view?.startAnimation(animation)
view?.alpha = 0.5f
view?.visibility = View.GONE
}
网友评论