我有一个AnimationDrawable
从可绘制资源中加载几帧的设备,但在某些设备上我得到OutofMemoryError: bitmap size exceeds VM budget.
了现在我已经阅读了有效地显示位图指南,但我无法将它与我的案例联系起来?
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();