在动画列表android的内存不足错误 [英] OutOfMemory Error in animation-list android

查看:164
本文介绍了在动画列表android的内存不足错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个100 +的图像(帧)在我​​的可绘制和他们每个人都是1-5 KBS尺寸(480高分辨X 272)。现在,当我在动画列表中添加XML这些图像(帧),并尝试运行它,我得到这个OutOfMemory错误,我搜索在互联网上,但无法找到我所期待的。所以任何人都可以请告诉我,我应该怎么做才能克服这种错误

I have like 100+ images(frames) in my drawables and each of them are 1-5 kbs size (with resolution 480 x 272). now when I add these images (frames) in animation-list xml and try to run it, I get this OutOfMemory error, I have searched on internet but couldn't find what I am looking for. so anyone can please tell me what should I do to overcome this error

推荐答案

阅读文章

做一件事,在manifest.xml

Do one thing in the manifest.xml

 <application

    android:largeHeap="true">

</application>

请拨打动画 runOnUiThread(Runnable的动作)的AsyncTask

单张图像需要的内存:

在这种情况下,你有100个图像,尺寸为400 * 262。

In this case you have 100 images and dimensions are 400*262.

因此​​,100 * 400 * 262 * 4 =? KB,尺寸发生在加载时间。如果动画正在超越虚拟堆内存的限制。

So , 100 * 400*262*4 = ? KB , size occur during the loading time. If the animation is exceeding the limit of Virtual Heap Memory.

错误会发生挑衅。

对于这样的:

减少尺寸图像

使用较少的图像,动画

分裂成两个动画文件后的一个完成启动另一个

split into two animation file after one completion start another one

编辑于2015年6月16日

尝试使用处理程序和几毫秒后调用句柄。这也将减少内存问题(OOM)。

Try to use Handler and call Handler after few millisecond. It will also reduce the memory issue(OOM).

这篇关于在动画列表android的内存不足错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆