知识点程序人生

Android 给指定View设置消失的动态效果

2021-06-26  本文已影响0人  为自己代颜_

直接上代码:

    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
    }
上一篇 下一篇

猜你喜欢

热点阅读