【发布时间】:2011-04-02 01:00:00
【问题描述】:
我有 2 个安静的大动画,每个 50pics 和 20kb 两者都定义为 Animations .xml
我让一个从头开始,第二个在单击按钮后开始。
//Start immediatly
imgView.setBackgroundResource(R.layout.anim1);
rocketAnimation = (AnimationDrawable) imgView.getBackground();
//Start after button click
imgView.setBackgroundResource(R.layout.anim2);
rocketAnimation = (AnimationDrawable) imgView.getBackground();
它工作正常,直到我按下按钮并将第二个动画分配给我的视图
08-22 14:56:03.886: DEBUG/AndroidRuntime(1541): Shutting down VM
08-22 14:56:03.886: WARN/dalvikvm(1541): threadid=3: thread exiting with uncaught exception (group=0x4001da28)
08-22 14:56:03.886: ERROR/AndroidRuntime(1541): Uncaught handler: thread main exiting due to uncaught exception
08-22 14:56:04.096: ERROR/AndroidRuntime(1541): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
08-22 14:56:04.096: ERROR/AndroidRuntime(1541): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
看起来每个动画本身都很好(我什至可以在自动启动时设置 anim2)。但两者都会超出内存。
顺便说一句。在我的 Nexus One 上运行完美。它失败的地方是 G1 1.6(即使在模拟器中)。
那么在分配 anim2 之前如何先释放 anim1 呢??
谢谢 克里斯
【问题讨论】:
标签: android memory-management animation