回收每一帧的图片,释放内存资源
private void tryRecycleAnimationDrawable(AnimationDrawable animationDrawables) {
if (animationDrawables != null) {
animationDrawables.stop();
for (int i = 0; i < animationDrawables.getNumberOfFrames(); i++) {
Drawable frame = animationDrawables.getFrame(i);
if (frame instanceof BitmapDrawable) {
((BitmapDrawable) frame).getBitmap().recycle();
}
frame.setCallback(null);
}
animationDrawables.setCallback(null);
}
}
回收完之后可以请求System.gc();回收