android-大图像导致应用程序崩溃
我正在使用平板电脑应用程序.我尝试使用Layout.setBackgroundResource(ResId)
将高分辨率(2223x3553)图像设置为背景.在Nexus 7
上进行测试时,应用程序崩溃了,我不会粘贴堆栈跟踪信息,因为LogCat
中有大约8或9个异常以及大约300条红线,我花了一些时间才弄清楚原因.我注意到OutOfMemoryException
之后,使用1280x800图像运行了该应用程序,但该应用程序运行良好,但由于将这些图像设计为高分辨率,因此出现了一些质量下降的情况.
I'm working on a tablet app. I tried to set high-resolution (2223x3553) images as background using Layout.setBackgroundResource(ResId)
. The app crashed while testing on Nexus 7
, I won't paste the stack traces since there were like 8 or 9 exceptions with about 300 red lines in the LogCat
and it took me a while to figure out the reason. I got it after I noticed the OutOfMemoryException
, using 1280x800 images the app runs fine but some quality loss has occurred since those images are designed to be high-res.
问题:如何在Android中处理高分辨率图像以防止此类崩溃?所有图像都是本地图像,并存储在drawable
文件夹
The question: how to handle high-resolution images in Android to prevent crashes like that? All images are local and stored in the drawable
folder
图像大小在android开发中受到限制.您不能使用大于规定图像的图像.有关如何为您的应用程序选择图像的准则.这是链接到准则.
Image sizes are limited in android development. You can not use images which are bigger than the prescribed ones. There is a guideline about how to choose images for your application. This is the link to the guidelines.