美文网首页知识点程序人生
Android 给指定View设置消失的动态效果

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

作者: 为自己代颜_ | 来源:发表于2021-06-26 12:00 被阅读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
    }

相关文章

网友评论

    本文标题:Android 给指定View设置消失的动态效果

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