Android的AnimationDrawable并知道何时动画结束 [英] Android AnimationDrawable and knowing when animation ends

查看:514
本文介绍了Android的AnimationDrawable并知道何时动画结束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要做一个动画的几个图像文件,这样做的AnimationDrawable工作得非常好。不过,我需要的时候动画开始就知道它结束时(即添加像Animation.AnimationListener侦听器)。有寻找答案之后,我有一种不好的预感在AnimationDrawable不支持的听众。

I want to do an animation with several image-files, and for this the AnimationDrawable works very well. However, I need to know when the animation starts and when it ends (i.e add a listener like the Animation.AnimationListener). After having searched for answers, I'm having a bad feeling the AnimationDrawable does not support listeners..

有谁知道怎么做帧一帧图像动画在Android?

Does anyone know how to do frame-by-frame image animation on Android?

推荐答案

您应该知道在启动时,因为你是一个开始吧。而且,由于你知道的持续时间(因为你指定它),你应该知道它何时结束。

You should know when it starts, as you're the one starting it. And, since you know the duration (since you specify it), you should know when it ends.

您也可以遍历所有的帧( getNumberOfFrames()),并总结了各(的持续时间getDuration()),如果您不想硬线在Java code的持续时间。

You can also iterate over all of the frames (getNumberOfFrames()) and sum up the durations of each (getDuration()), if you do not want to hard-wire a duration in your Java code.

这篇关于Android的AnimationDrawable并知道何时动画结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆