Android的:在内存消耗巨大差异VS绘制-nodpi使用的文件夹时,绘制 [英] Android: Huge difference in memory consumption when using drawable vs drawable-nodpi folders
问题描述
我与Android Studio创建与的ImageView
这样的装载单一的形象基本的Android应用程序:
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 indrawable
folder runtime memory consumed by app is 24.35 MB vs 11.85 MB when image is stored indrawable-nodpi
folder. Tested onxhdpi
device with resolution of1280x720 pix
.In my real life app, difference is even greater 75 MB vs 25 MB.
Why the difference? I thought that
drawable
anddrawable-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屋!