Q :最近使用studio 发现drawle-hdpi 都没有了换成了mipmap-hdpi,这两个目录有什么区别呢,哪个比较好呢???

A:

我简单总结一下:

使用上没有任何区别,你把它当drawable用就好了。

但是用mipmap系统会在缩放上提供一定的性能优化。

官方介绍:

Mipmapping for drawables

Using a mipmap as the source for your bitmap or drawable is a simple way to provide a quality image and various image scales, which can be particularly useful if you expect your image to be scaled during an animation.

Android 4.2 (API level 17) added support for mipmaps in the Bitmap class—Android swaps the mip images in your Bitmap when you've supplied a mipmap source and have enabled setHasMipMap(). Now in Android 4.3, you can enable mipmaps for a BitmapDrawable object as well, by providing a mipmap asset and setting the android:mipMap attribute in a bitmap resource file or by calling hasMipMap().

应用场景:

If you know that you are going to draw this bitmap at less than 50% of its original size, you may be able to obtain a higher quality by turning this property on. Note that if the renderer respects this hint it might have to allocate extra memory to hold the mipmap levels for this bitmap.

一个应用实例:

Nexus 6

Screen
The Nexus 6 boasts an impressive 5.96” Quad HD screen display at a resolution of 2560 x 1440 (493 ppi). This translates to ~ 730 x 410 dp (density independent pixels).

Check your assets
It has a quantized density of 560 dpi, which falls in between the xxhdpi and xxxhdpi primary density buckets. For the Nexus 6, the platform will scale down xxxhdpi assets, but if those aren’t available, then it will scale up xxhdpi assets.

Provide at least an xxxhdpi app icon because devices can display large app icons on the launcher. It’s best practice to place your app icons in mipmap- folders (not the drawable- folders) because they are used at resolutions different from the device’s current density. For example, an xxxhdpi app icon can be used on the launcher for an xxhdpi device.

res/
mipmap-mdpi/
ic_launcher.png
mipmap-hdpi/
ic_launcher.png
mipmap-xhdpi/
ic_launcher.png
mipmap-xxhdpi/
ic_launcher.png
mipmap-xxxhdpi/
ic_launcher.png # App icon used on Nexus 6 device launcher

Choosing to add xxxhdpi versions for the rest of your assets will provide a sharper visual experience on the Nexus 6, but does increase apk size, so you should make an appropriate decision for your app.

res/
drawable-mdpi/
ic_sunny.png
drawable-hdpi/
ic_sunny.png
drawable-xhdpi/
ic_sunny.png
drawable-xxhdpi/ # Fall back to these if xxxhdpi versions aren’t available
ic_sunny.png
drawable-xxxhdpi/ # Higher resolution assets for Nexus 6
ic_sunny.png

总结

这个实例总结一下是这样:

Nexus 6 有 493 ppi,它刚好在 xxhdpi和xxxhdpi之间,所以显示的时候需要对xxxhdpi的资源进行缩小,如果你用了mipmap-xxxhdpi,那么这里会对sclae有一个优化,性能更好,占用内存更少。所以现在官方推荐使用mipmap:

It’s best practice to place your app icons in mipmap- folders (not the drawable- folders) because they are used at resolutions different from the device’s current density.

本文转自:http://segmentfault.com/q/1010000002603418

mipmap 目录和drawable 目录有什么区别的更多相关文章

  1. selector在color和drawable目录下的区别

    selector作为drawable资源时,放于drawable目录下,并且item指定android:drawable属性,引用使用@drawable而不是@color selector作为colo ...

  2. 【android studio】解决android studio drawable新建项目时只有一个drawable目录的问题

    概述 android studio默认新建Module时,只新建一个drawable目录,并不会新建适配不同分辨率的drawable目录.但其实,这是可以设置的.有以下两种方法: 方法1 详细步骤 进 ...

  3. res/drawable目录下图片的Uri

    http://liuyun025.iteye.com/blog/1280838 有时候,我们要用到res/drawable目录下的图片Uri,而这个Uri该如何生存呢?下面就是这Uri的生成方法: U ...

  4. Android应用开发多语言drawable目录

    Android程序多语言的支持是就该Value目录不同国家的区分,前面文档有介绍相相应的国家名称Value怎样写 例如以下说下多语言图片的替换也是就该图片目录目录drawable目录例如以下: Bac ...

  5. Android开发系列(十八):自己定义控件样式在drawable目录下的XML实现

    在Android开发的过程中,我们常常须要对控件的样式做一下改变,能够通过用添加背景图片的方式进行改变,可是背景图片放多了肯定会使得APK文件变的非常大. 我们能够用自己定义属性shape来实现. s ...

  6. Nginx设置alias实现虚拟目录 alias与root的用法区别

    Nginx 貌似没有虚拟目录的说法,因为它本来就是完完全全根据目录来设计并工作的.如果非要给nginx安上一个虚拟目录的说法,那就只有alias标签比较"像",干脆来说说alias ...

  7. C#项目中的bin目录和obj目录的区别

    C#项目中的bin目录和obj目录的区别 1.关于bin目录和obj目录 Bin目录用来保存项目生成后程序集,它有Debug和Release两个版本,分别对应的文件夹为bin/Debug和bin/Re ...

  8. python入门-PyCharm中目录directory与包package的区别及相关import详解

    一.概念介绍 在介绍目录directory与包package的区别之前,先理解一个概念---模块 模块的定义:本质就是以.py结尾的python文件,模块的目的是为了其他程序进行引用. 目录(Dict ...

  9. PyCharm中目录directory与包package的区别及相关import详解

    一.概念介绍 在介绍目录directory与包package的区别之前,先理解一个概念---模块 模块的定义:本质就是以.py结尾的python文件,模块的目的是为了其他程序进行引用. 目录(Dire ...

随机推荐

  1. Assembly(c#中简单说明[转]

    什么是Assembly(程序集)?Assembly是一个包含来程序的名称,版本号,自我描述,文件关联关系和文件位置等信息的一个集合.在.net框架中通过Assembly类来支持,该类位于System. ...

  2. yum downloadonly

         有些时候集群中的机器无法联网,通过yum进行安装,这样就需要找一个相同内核的机器将rpm下载后再到相应的机器上进行安装,以解决这一问题.      yum 有相应的工具完成这一任务.     ...

  3. Textures

    LPDIRECT3DVERTEXBUFFER9 g_VertexBuffer=NULL; //顶点缓存 LPDIRECT3DTEXTURE9 g_Texture=NULL;//纹理对象 bool In ...

  4. POJ 3710 Christmas Game

    知识储备: 解决办法(奇偶去环):   (1) 对于长度为奇数的环,去掉其中任意一个边之后,剩下的 两个链长度同奇偶,抑或之后的 SG 值不可能为奇数,所 以它的 SG 值为 1: (2) 对于长度为 ...

  5. C/C++类型转换

    1.隐式类型转换 1.1 隐式类型转换的规则 K & R A.6.5 Arithmetic Conversions(数值型间的转换)First, if either operand is lo ...

  6. 查看程序是否启动或者关闭--比如查看Tomcat是否开启!直接用ps命令查看进程就行了啊

    1.查看程序是否启动或者关闭--比如查看Tomcat是否开启!直接用ps命令查看进程就行了啊 2.Tomcat服务器和虚拟机的关系,Tomcat启动运行过程要调用系统环境变量的java_home啊,J ...

  7. Hadoop2.2.0 安装笔记

    在Youtube上找到靠谱的教程:http://www.youtube.com/watch?v=WN2tJk_oL6E 同时把作者的教程下载下来放在百度云盘上了:http://pan.baidu.co ...

  8. OpenMp之false sharing

    关于false sharing的文章,网上一大堆了,不过觉得都不太系统,那么下面着重系统说明一下. 先看看外国佬下的定义: In symmetric multiprocessor (SMP) syst ...

  9. Lucene学习笔记(更新)

    1.Lucene学习笔记 http://www.cnblogs.com/hanganglin/articles/3453415.html    

  10. Android内存管理(3)缓存不要用SoftReference, 用android.util.LruCache

    A reference that is cleared when its referent is not strongly reachable and there is memory pressure ...