我有大约100张图片,我想在图片视图中加载它。它以某种方式崩溃并向我显示错误。如何按顺序将更多图像加载到单个图像视图中。我还想在特定帧之后调用一些文本。就像每20帧后我想要显示文字。知道我该怎么办?
java.lang.OutOfMemoryError: Failed to allocate a 2419212 byte allocation with 160148 free bytes and 156KB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:726)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:547)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1014)
at android.content.res.Resources.loadDrawableForCookie(Resources.java:3747)
at android.content.res.Resources.loadDrawable(Resources.java:3620)
at android.content.res.Resources.getDrawable(Resources.java:1852)
at android.graphics.drawable.AnimationDrawable.inflate(AnimationDrawable.java:319)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1150)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1063)
at android.content.res.Resources.loadDrawableForCookie(Resources.java:3736)
at android.content.res.Resources.loadDrawable(Resources.java:3620)
at android.content.res.Resources.getDrawable(Resources.java:1852)
at android.support.v7.widget.ResourcesWrapper.getDrawable(ResourcesWrapper.java:133)
at android.content.Context.getDrawable(Context.java:408)
at android.view.View.setBackgroundResource(View.java:17228)
at android.support.v7.widget.AppCompatImageView.setBackgroundResource(AppCompatImageView.java:83)
at com.example.aakash.giftry.MainActivity.onCreate(MainActivity.java:22)
at android.app.Activity.performCreate(Activity.java:6289)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758)
at android.app.ActivityThread.access$900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5942)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
答案 0 :(得分:0)
<application
android:hardwareAccelerated="false"
android:largeHeap="true"
>
在清单
中添加这些行答案 1 :(得分:0)
你需要释放不可见抽屉的记忆。有点像这样:
if (previousBitMap != null){
previousBitMap.recycle();
previousBitMap = null;
}
[...] // load next
选中此项,如何正确执行:Causing OutOfMemoryError in Frame by Frame Animation in Android