结束动画事件android
我在视图中有一个淡出动画(位于片段内),每次动画发生时,视图完成后都会再次重新绘制自身。我找到了一种解决方法 view.SetVisibility(View.GONE)
。但它不会等待动画完成。我想仅在动画完成后执行此 setVisibility 代码。最好的方法是什么?
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 around doing view.SetVisibility(View.GONE)
. But it doesn't wait for the animation to finish. I would like to execute this setVisibility code only after the animation has finished. What is the best way to do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以将动画侦听器添加到动画对象中,例如
You can add Animation listener to your animation object like
功能上与已接受的答案相同,但以更简洁的方式:
享受:)
Functionally the same as the accepted answer but in a much more concise way:
Enjoy :)
只需获取您的动画对象并向其添加动画侦听器即可。
这是示例代码:
Simply take your animation object and add animation listener to it.
Here is the example code :
您还可以使用 Animation.setFillAfter
You can also achieve this using Animation.setFillAfter
Kotlin 的示例
Example for Kotlin