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. linux系统下挂载windows共享目录

    在工作中有时我们需要在linux上挂载windows共享目录.首先我们需要学会在linux上查看windows共享了那些目录.查看操作需要安装samba-client. [root@ ~]# yum ...

  2. Facebook揭密:如何让MySQL数据库集群自主运行

    Facebook运行着全球最大的MySQL数据库集群,该集群分布在两个大洲上的多个数据中心中数以千计的服务器上.让人不解的是,Facebook只动用了一个很小的团队来管理这个庞大的MySQL数据库集群 ...

  3. Android核心分析 之九Zygote Service

    Zygote Service 在本章我们会接触到这两个单词: Zygote [生物] 受精卵, 接合子, 接合体 Spawn:产卵 通过这两个单词,我们就可以大体知道Zygote是干什么的了,就是叫老 ...

  4. 在linux/unix中查找大文件

    在linux/unix中查找大文件,如查找大于100M文件的位置路径,查找等于10M文件的位置路径等等,下面就介绍几个实现快速查找的命令: 1. 查找指定目录下所有大于100M的文件,命令为 find ...

  5. iOS:iPad和iPhone开发的异同(UIPopoverController、UISplitViewController)

    iPad和iPhone开发的异同 1.iPhone和iPad: niPhone是手机,iPad.iPad Mini是平板电脑 iPhone和iPad开发的区别 屏幕的尺寸 \分辨率 UI元素的排布 \ ...

  6. Oracle ->> 变量赋值 Demo

    刚学Oracle,学习学习别人的代码.这段代码时从下面的博文中摘取的:http://www.cnblogs.com/mq0036/p/4155774.html declare l_dept ; cur ...

  7. Spring boot 整合jsp和tiles模板

    首先贴上我的pox.xml文件,有详细的支持注释说明 <?xml version="1.0" encoding="UTF-8"?> <proj ...

  8. javascript 阻止冒泡

    JS  阻止冒泡 function stopBubble(e) { //如果提供了事件对象,则这是一个非IE浏览器 if(e && e.stopPropagation) { //因此它 ...

  9. pyhton小方法

    import osa = os.walk('.') for i in a: print(i)

  10. HTML发展历史

    概述 HTML从1993到如今的发展,同时针对其以后的发展进行评测. HTML 语言作为网络语言标准规范,在计算机的发展史中有着不可或缺的地位.在HTML 上的成就也决定着一个时代的发展. 1.HTM ...