How do I do something when an animation finishes?

前端 未结 4 1128
攒了一身酷
攒了一身酷 2020-12-01 08:51

I have an ImageView that I use to show progress via an AnimationDrawable. When I want to show my progress spinner, I do this:

anim         


        
4条回答
  •  南笙
    南笙 (楼主)
    2020-12-01 09:28

    With androidx you can use doOnEnd method which invoked when the animation has ended

    val anim = ObjectAnimator.ofFloat(eva_image, View.TRANSLATION_Y, 0f, 500f)
    anim.setDuration(500)
    anim.doOnEnd { Toast.makeText(this, "Anim End", Toast.LENGTH_SHORT).show() }
    anim.start()
    

提交回复
热议问题