onAnimationEnd虽然animation.hasEnded设置为true,但是当事件被触发时,似乎没有真正完成Android动画.
我希望我的视图可以改变它的背景可绘制的背景ScaleAnimation,但你可以清楚地看到它在完成之前已经改变了几毫秒.问题是,它会闪烁,因为新的背景会出现(=)缩放很短的时间,直到动画完成.
有没有办法获得动画的真实结束,或者只是阻止新背景在这么短的时间内缩放?
谢谢!
//编辑:我正在使用一个AnimationListener来接听以下电话:
@Override
public void onAnimationEnd(Animation animation)
{
View view = (MyView) ((ExtendedScaleAnimation) animation).getView();
view.clearAnimation();
view.requestLayout();
view.refreshBackground(); // <-- this is where the background gets changed
}
Run Code Online (Sandbox Code Playgroud) 我正在移动图像,我想在对象的动画完成后播放声音文件
图像移动但我尝试使用线程等待持续时间但它不起作用.
Animation animationFalling = AnimationUtils.loadAnimation(this, R.anim.falling);
iv.startAnimation(animationFalling);
MediaPlayer mp_file = MediaPlayer.create(this, R.raw.s1);
duration = animationFalling.getDuration();
mp_file.pause();
new Thread(new Runnable() {
public void run() {
try {
Thread.sleep(duration);
mp_file.start();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}).start();
Run Code Online (Sandbox Code Playgroud)
谢谢.