我有一个25帧的压缩jpeg动画,总共不到2mb。
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true">
<item android:drawable="@drawable/y1" android:duration="50" />
<item android:drawable="@drawable/y2" android:duration="50" />
...
<item android:drawable="@drawable/mouse" android:duration="50" />
</animation-list>
然而当我尝试玩
iv.setBackgroundResource( R.anim.yawn );
AnimationDrawable anim = (AnimationDrawable)iv.getBackground();
anim.start();
它因位图大小超过VM预算而崩溃。
有什么想法吗?
谢谢!
如果只是减少"占空比"。。。有一次我在OutOfMemory处理图像时出错,但有点像。。。。帮助了我…代码在上面。。。
private void unbindDrawables(View view) {
if (view.getBackground() != null) {
view.getBackground().setCallback(null);
}
if (view instanceof ViewGroup) {
for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
unbindDrawables(((ViewGroup) view).getChildAt(i));
}
((ViewGroup) view).removeAllViews();
}
}