End animation event android

前端 未结 5 957
隐瞒了意图╮
隐瞒了意图╮ 2020-12-05 12:34

I have a fadeout animation in a view (which is inside a fragment), and everytime the animation happens, after it finishes the view redraws itself again. I found a work aroun

5条回答
  •  没有蜡笔的小新
    2020-12-05 13:06

    Example for Kotlin

    var fadeOutImage = findViewById(R.id.fade_out_Image)
        val fadeOutAnimation = R.anim.fade_out_animation
        val animation = AnimationUtils.loadAnimation(this, fadeOutAnimation)
        fadeOutImage.startAnimation(animation)
    
        animation.setAnimationListener(object : Animation.AnimationListener {
            override fun onAnimationStart(p0: Animation?) {
    //                not implemented
            }
    
            override fun onAnimationRepeat(p0: Animation?) {
    //                not implemented
            }
    
            override fun onAnimationEnd(p0: Animation?) {
                fadeOutImage.visibility = View.INVISIBLE
            }
        })
    

提交回复
热议问题