本文介绍了结束动画事件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?
推荐答案
你可以像这样为你的动画对象添加 Animation 监听器
You can add Animation listener to your animation object like
anim.setAnimationListener(new Animation.AnimationListener(){
@Override
public void onAnimationStart(Animation arg0) {
}
@Override
public void onAnimationRepeat(Animation arg0) {
}
@Override
public void onAnimationEnd(Animation arg0) {
}
});
这篇关于结束动画事件android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!