Android的:在内存消耗巨大差异VS绘制-nodpi使用的文件夹时,绘制 [英] Android: Huge difference in memory consumption when using drawable vs drawable-nodpi folders

查看:222
本文介绍了Android的:在内存消耗巨大差异VS绘制-nodpi使用的文件夹时,绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与Android Studio创建与的ImageView 这样的装载单一的形象基本的Andr​​oid应用程序:

  ImageView的IV =(ImageView的)findViewById(R.id.imageView);
iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
iv.setImageResource(R.drawable.g01);

图像尺寸 1280x853 PIX ,没有什么巨大的。当我存储在由应用程序消耗绘制文件夹运行时内存的形象是24.35 MB VS时,图像存储在 11.85 MB绘制-nodpi 文件夹中。经测试 xhdpi 1280×720 PIX 的分辨率设备上。

在我的现实生活中的应用,不同的是更大的75 MB和25 MB。

为什么会有差别?我认为,绘制绘制-nodpi 文件夹基本上是相同的,并服务于同一目的?


解决方案

  

为什么会有差别?我认为,绘制和绘制,nodpi文件夹
  基本上是相同的,并服务于同一目的?


没有他们不是。 绘制秤每设备的密度它的内容,绘制-nodpi 没有。在第一种情况下,你会得到一个位图密度的时间宽度/高度原来的

I have basic Android application created with Android Studio with single image loaded in ImageView like this:

ImageView iv = (ImageView)findViewById(R.id.imageView);
iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
iv.setImageResource(R.drawable.g01);

Image size is 1280x853 pix, nothing huge. When I store the image in drawable folder runtime memory consumed by app is 24.35 MB vs 11.85 MB when image is stored in drawable-nodpi folder. Tested on xhdpi device with resolution of 1280x720 pix.

In my real life app, difference is even greater 75 MB vs 25 MB.

Why the difference? I thought that drawable and drawable-nodpi folders are basically the same and serve the same purpose?

解决方案

Why the difference? I thought that drawable and drawable-nodpi folders are basically the same and serve the same purpose?

No they are not. drawable scales its content per the device's density, drawable-nodpi doesn't. In the first case you will get a bitmap density time width/height the original one

这篇关于Android的:在内存消耗巨大差异VS绘制-nodpi使用的文件夹时,绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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