mipmap 目录和drawable 目录有什么区别

http://segmentfault.com/q/1010000002603418

使用上没有任何区别,你把它当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.

时间: 2024-08-13 21:18:25

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

android中libs目录下armeabi和armeabi-v7a的区别

在我们android APK的根目录有一个 libs文件夹,此文件夹下包含了armeabi 和armeabi-v7a两个文件夹,我们的c代码编译成的本地库(各种.so)就会放在这两个文件夹其中的一个.那armeabi-v7a 与 armeabi有什么区别,都是什么意思呢? armeabi和armeabi-v7a是表示cpu的类型,我们知道一般的手机或平板都是用arm的cpu(mips的就悲催的被忽视了),不同的cpu的特性不一样,armeabi就是针对普通的或旧的arm cpu,armeabi-

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

在Android开发的过程中,我们常常须要对控件的样式做一下改变,能够通过用添加背景图片的方式进行改变,可是背景图片放多了肯定会使得APK文件变的非常大. 我们能够用自己定义属性shape来实现. shape: gradient   -- 相应颜色渐变. startcolor.endcolor就不多说了. android:angle 是指从哪个角度開始变. solid      --  填充. stroke   --  描边. corners  --  圆角. padding   -- 定义内容

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

Nginx 貌似没有虚拟目录的说法,因为它本来就是完完全全根据目录来设计并工作的.如果非要给nginx安上一个虚拟目录的说法,那就只有alias标签比较"像",干脆来说说alias标签和root标签的区别吧.最基本的区别:alias指定的目录是准确的,root是指定目录的上级目录,并且该上级目录要含有location指定名称的同名目录.另外,根据前文所述,使用alias标签的目录块中不能使用rewrite的break. 说不明白,看下配置: location /abc/ { alias

linux下目录读权限与执行权限区别

如果你在linux下用过ls,细心的你会发现目录竟然有可执行权限!如: drwxrwxr-x 11 cl cl 4096  9月 25 14:22 ./ drwxr-xr-x 49 cl cl 4096 10月 10 16:00 ../ drwxrwxr-x  5 cl cl 4096  9月 23 10:58 algorithm/ drwxrwxr-x  2 cl cl 4096  9月 23 21:44 temp/ why?? 在网上查了一下才发现是这个意思: 目录的可执行权限是表示你可否在

Python入门之PyCharm中目录directory与包package的区别

对于Python而言,有一点是要认识明确的,python作为一个相对而言轻量级的,易用的脚本语言(当然其功能并不仅限于此,在此只是讨论该特点),随着程序的增长,可能想要把它分成几个文件,以便逻辑更加清晰,更好维护,亦或想要在几个程序中均使用某个函数,而不必将其复制粘贴到所有程序中. 为了支持这一点,Python有一种方法将定义函数放在一个文件中,并在脚本中使用它们,这样的文件叫做模块,一个模块中的定义可以被导入到其他模块,或者主模块中. 简单来说在python中模块就是指一个py文件,如果我们将

目录与文件权限的意义区别

这些文件权限对于数据安全的重要性.那么,这些文件权限对于一般文件与目录文件有何不同呢? 1.权限对文件的重要性 文件是实际含有数据的地方,包括一般文本文件.数据库内容档.二进制可可执行文件(binary program)等等. 因此,权限对于文件来说,他的意义是这样的: r (read):可读取此一文件的实际内容,如读取文本文件的文字内容等: w (write):可以编辑.新增或者是修改该文件的内容(但不含删除该文件): x (eXecute):该文件具有可以被系统执行的权限. 那个可读(r)代

Linux常见的重要目录及各目录作用

以下是linux系统常见的重要目录以及各个目作用:/ 根目录.包含了几乎所的文件目录.相当于中央系统.进入的最简单方法是:cd /. /boot引导程序,内核等存放的目录. 这个目录,包括了在引导过程中所必需的文件,引导程序的相关文件(例如grub,lilo以及相应的配置文件以及Linux操作系统内核相关文件(例如vmlinuz等一般都存放在这里.在最开始的启动阶段,通过引导程序将内核加载到内存,完成内核的启动(这个时候,虚拟文件系统还不存在,加载的内核虽然是从硬盘读取的,但是没经过Linux的

tomcat webapps目录和ROOT目录

1,webapps和ROOT目录有什么区别联系 各自有什么作用 基本一样, 只是表示不同的tomcat的http路径而已 2,webapps目录是工作目录 那么 工作目录又是什么呢 tomcat如何处理这个工作目录呢 真正的工作目录在server.xml中配置, tomcat为了方便, 默认一个webapps而不用配置. 这里的配置是http目录和本地文件目录的映射 3,http://localhost:8080/  如何理解最后的那个"/" 表示http的根/root 修改默认路径的

附加依赖项、库目录、包含目录

附加依赖项(lib): 一种逻辑关系,a依赖b. 库目录(libs): 包含目录(include): https://blog.csdn.net/u012043391/article/details/54972127 VS项目中的包含目录.库目录.附加包含目录.附加库目录.附加依赖项均在"项目->属性->配置属性"下进行配置,具体说明如下: VC++目录: 包含目录:寻找#include<xxxx.h>中的xxxx.h的搜索目录 库目录:寻找.lib文件的搜索目