安卓动画内存泄漏

3

如果我的活动中有无限的动画,然后我导航离开该活动,会导致内存泄漏吗?我是否需要显式停止动画,还是在框架级别上会自动管理?我所说的无限动画是什么意思:

<?xml version="1.0" encoding="utf-8"?>

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false"
    android:repeatCount="infinite">

<rotate
    android:duration="1000"
    android:interpolator="@android:anim/linear_interpolator"
    android:pivotX="50%"
    android:pivotY="50%"
    android:repeatCount="infinite"
    android:repeatMode="restart"
    android:toDegrees="360" />

2个回答

1

0

虽然不是非常相关,但如果泄漏是由Animator类引起的,例如持有对Activity/Fragment的引用,您应该在片段/活动的 onDestroy 回调中调用 animatorInstance.removeAllListeners()


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接