OutofMemoryError,位图大小超过VM预算。在一个帧动画中

时间:2013-07-24 12:20:14

标签: android performance android-animation

我有AnimationDrawable从可绘制资源中加载少量帧,但在某些设备上我得到OutofMemoryError: bitmap size exceeds VM budget.
现在我已经阅读了Displaying Bitmaps Efficiently指南,但我无法将其与我的案例联系起来?

if (animation == null)
        animation = new AnimationDrawable();

    for (int i = 0; i <= numOfFrames; i++){
        int resourceID = 
                context.getResources().getIdentifier(frameName + i, "drawable" ,
                        context.getPackageName());
        animation.addFrame(context.getResources().getDrawable(resourceID), 
                frameDuration);
    }
    animation.setOneShot(false);

    if(Build.VERSION.SDK_INT >= 16)
        pb.setBackground(animation);
    else
        pb.setBackgroundDrawable(animation);

    animation.start();

0 个答案:

没有答案