android-大图像导致应用程序崩溃 [英] android - large images cause app crash

查看:197
本文介绍了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.

这篇关于android-大图像导致应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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