Android应用2.2端口4.0 [英] Android app 2.2 port to 4.0

查看:114
本文介绍了Android应用2.2端口4.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了基于2.2.It应用程序正常工作,并做得很好。然而,当我把应用程序在4.0(分辨率1280×800三星Galaxy Note)。它崩溃并说,它运行的内存随机和错误的布局,没有按;吨固定尺寸

I have built an application based on 2.2.It works properly and does well. However, when i put the application on the 4.0(with resolution 1280x800 Samsung Galaxy Note). It crashes and says it runs out of memory randomly and with wrong layout which doesn;t fix the size

下面是我的情况,
我有5个活动(通常1的背景图像,重点和正常的20键的背景图像)以及约2MB的文件大小。

Here is my situation, I have totally about 100 images(most of them are .png and .jpg) within 5 activities (normally 1 background image,20 button background images with focus and normal one) and about 2MB in file size.

我将像相对布局背景或按钮的背景或只是ImageView的XML中的图像和布局。

I set the image and layout in the xml like relative layout background or button background or just imageview.

我不知道只是2MB,为什么它运行的内存和为什么它在2.2的工作,但不能在4.0。

I wonder why it runs out of memory as in the drawable folder size is just 2MB and why it runs out of memory and why does it work on 2.2 but fail on 4.0.

我希望如果有人能帮助我。

I hope if anyone can help me.

首先关注的是布局。例如,按钮大小是比在2.2比较大。所以,恐怕它的比例可能会影响到内存的问题。在我的按钮XML,我将其设置为可WRAP_CONTENT为宽度和height.I不知道为什么它会比大我的预期。我的想法是有在4.0布局XML一些差异,就会使布局奇怪或做一些规模则会使内存奇怪。事实上,所有的图像都只是2MB,是有可能出现内存不足?

The first concern is the layout. For example, the button size is relatively large than the one in 2.2. So I am afraid of its scaling may affect the memory issue. In my button xml,i set it to be wrap_content for both width and height.I have no idea why it will be large than i expected. My thought is there are some differences on the layout xml in 4.0, it will make the layout strange or doing some scale then make the memory strange. In fact, all the images are just 2MB,is it possible to run out of memory?

第二个问题是memory.May是内存处理是从previous version.So不同做我需要做一些调整,以使其工作在4.0吗?忽视布局的问题,可能是我可以进一步校准位置和size.But现在我无法显示的布局,所以我想有些事情需要做4.0?

The second concern is the memory.May be the memory handling is different from previous version.So do i need to make some adjustment in order to make it works on 4.0? Neglect the layout problem,may be i can further calibrate the position and size.But now i am unable to display the layout so I guess there is something to do on 4.0?

最后,才可能找出多少内存中为每个ImageView的或按钮使用吗?这个工具,可能会进一步调查该问题。

Finally,is it possible to find out how much memory used for each imageView or button? with this tools,may be can further investigate the problem.

如果你有时间,请帮助我。

If you are free,please help me.

推荐答案

试着将你的图像绘制相应的文件夹,如绘,MDPI,绘制,华电国际等。

Try placing your images in corresponding drawable folders such as drawable-mdpi, drawable-hdpi and so on.

如果你只有一个版本,尝试把它们绘-nodpi。您可能需要选择把哪些在nodpi取决于你的布局是如何设置。

if you only have one version try putting them in drawable-nodpi. You might need to select which ones to put in nodpi depending on how your layout is setup.

在自绘或绘制,于mdpi一个xhdpi或HDPI设备负载可绘制,系统将自动扩大资源相匹配的DPI。从MDPI到xhdpi的绘制将调整为2倍适用于mdpi到华电国际的尺寸和1.5倍。

when a xhdpi or hdpi device loads drawables from drawable or drawable-mdpi, the system automatically enlarged the resource to match the dpi. from mdpi to xhdpi the drawable will be resized to 2x the size and 1.5x for mdpi to hdpi.

希望这有助于:)

这篇关于Android应用2.2端口4.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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