我正在与我认为是一个巨大的错误在这里的操作系统。这就是我想要做的。
我在视图上有一个带有简单无限AnimatorSet动画的活动:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:ordering="sequentially" >
<objectAnimator
android:duration="1000"
android:propertyName="alpha"
android:repeatCount="infinite"
android:repeatMode="reverse"
android:valueFrom="0.3"
android:valueTo="1.0" />
</set>这个动画基本上是逐渐淡出视图,然后是。动画作品。
在活动的onDestroy()方法中,我使用animation.end()结束动画。
所发生的情况是,即使活动被破坏,应用程序的进程仍然使用处理器时间:

这是没有意义的,因为活动是关闭的。
我对此进行了一次又一次的测试,并删除了AnimatorSet修复了这个问题。
我还尝试过几种不同的方法来删除AnimatorSet : animation.end()、animation.cancel()、动画= null
你们觉得怎么样?
发布于 2013-11-11 18:16:14
好像我用错了:
我所做的:
onCreate(){
animation = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.animation);
animation.setTarget(myView);
animation.start();
}
onDestroy(){
if(animation != null){
animation.cancel();
}
}
onPause(){
if(animation != null){
animation.end();
}
}
onResume(){
if(animation != null){
animation.start();
}
}修复了这个:
onCreate(){
animation = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.animation);
animation.setTarget(myView);
animation.start();
}
onDestroy(){
if(animation != null){
animation.cancel();
}
}
onPause(){
if(animation != null && animation.isStarted()){
animation.end();
}
}
onResume(){
if(animation != null && !animation.isStarted()){
animation.start();
}
}https://stackoverflow.com/questions/19912736
复制相似问题