`
iaiai
  • 浏览: 2144786 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

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

 
阅读更多
使用上没有任何区别,你把它当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.
分享到:
评论

相关推荐

    清楚android项目工程drawable/mipmap/layout/menu路径下无用的资源文件

    shell脚本编写的功能,在Linux和mac终端上运行;主要用于Android studio下的Android项目,自动清除项目drawable、mimap、layout和menu下无用的资源文件

    drawable跟随TextView居中.zip

    drawable = ContextCompat.getDrawable(getContext(), R.mipmap.xxx); setDrawable(DrawableTextView.LEFT, drawable, width, height); Customizable attributes xml中定义了以下属性 Define xmlns:app=...

    Android drawable微技巧,你不知道的drawable细节

    话说微技巧这个词也是我自己发明的,因为drawable这个东西相信大家天天都在使用,每个人...但是如果你现在使用Android Studio来新建一个项目,你会发现有如下的目录结构: 嗯?怎么会有这么多mipmap开头的文件夹,而且

    Android Studio 3.0中mipmap-anydpi-v26是什么东东

    根据我们的理解,所有xml文件是保存在drawable目录下而不是mipmap中的。 Android Studio 3.0会为您的应用程序创建一个自适应图标,该图标仅在sdk 26中可用。启动图标应放入mipmap文件夹中。 如果这时候你去看你的...

    详解Android中Drawable方法

    新建在drawable目录下面,示例如下: <bitmap xmlns:android=http://schemas.android.com/apk/res/android android:antialias=true android:dither=true android:filter=true android:gravity=center ...

    Drawable Badge是一个Android库,用于向可绘制对象添加徽章。-Android开发

    用法生成带有徽章的drawableval drawable = DrawableBadge.Builder(context).drawableResId(R.mipmap.ic_launcher_roun Drawable Badge Drawable Badge是一个用于向可绘制对象添加徽章的android库。 ....

    Android 快速图片加载框架-Android开发

    支持加载网络图片(String格式url)/本地资源(mipmap和drawable)/网络.9图片/gif加载/自定义样式(圆形/圆角/centerCrop)/dataBinding Demo效果图 说明 支持加载网络图片(String格式url)/本地资源(mipmap和drawable...

    安卓.9图片转换软件.zip

    生成 .9 后缀到可拉伸图片。将生成到文件放入android mipmap 或drawable 中。使用图片时可根据设置图片可拉伸到长宽位置,将其进行拉伸、缩减

    Fast Image Resizer:跨平台应用程序来调整图像大小并将它们添加到文件夹中。-开源

    Javafx 应用程序来调整图像大小并将它们自动添加到文件夹中。... - 选择输出目录(drawable 或 mipmap)。 - 删除选定的图像。 - 按 显示所选图像。 - 显示图像的信息细节(类型 - 尺寸 - 尺寸)。

    ApkShellext2_v2.0.7_CN.7z

    1代只支持图标放在drawable文件夹下,2代修改为支持放在mipmap文件夹下的apk. 使用方式: 1、解压 2、管理员权限运行install.bat 3、运行restart_explorer.bat重启资源管理器或者注销账号重新登录 4、如需卸载,可以...

    省市区/县,详细地址选择自定义控件

    自定义控件 使用方法: android:id="@+id/test_edit" ... ,R.drawable.edit_bg,40,16f,R.mipmap.arrow_top ,R.mipmap.arrow_bottom,35,-38f); 获取自定义控件选择的值 listEditTextView.getPath();

    Android项目设计与开发:图像控件ImageView.ppt

    嵌入式Android项目设计与开发 第四章 ... ImageView 应用: 把准备好的图片存放在drawable或mipmap的资源目录中。 在布局中插入一个ImageView 通过布局选择图片或者Java代码加载资源文件 实验 谢谢 请专家批评指正!

    SuperButton-这真的可能是最好用的按钮了.zip

    这本来没有什么问题,也比让UI妹纸切图高级了很多,但是随着开发的进行你会发现,UI妹纸的想法很多,不同的界面有各种不同圆角和不同背景颜色的按钮,这个时候你需要把上面的三个步骤再进行N次。最后你会发现你的...

    基于android studio实现通讯录管理系统源代码,安卓移动开发课程设计

    使用android studio 导入项目,修改文件定制自己想要的布局风格以及功能 ...文件中的按钮背景文件在drawable文件夹下 所用到的icon资源位于mipmap文件夹下 values文件夹下声明了部分文字以及颜色样式。

    安卓夜间模式开发【深色主题适配】

    如果适配图片的话,就创建对应的 drawable-night目录。  正常情况下,系统会调用values里面的颜色还有主题等信息,当切换到深色模式的时候,系统就会调用“-night”的文件夹里面的信息,所以当你需要深色模式的...

    android studio实现安卓移动开发课程设计通讯录管理系统源代码.zip

    安卓移动开发课程设计通讯录管理系统源代码 使用说明: 使用android studio 导入项目,...文件中的按钮背景文件在drawable文件夹下 所用到的icon资源位于mipmap文件夹下 values文件夹下声明了部分文字以及颜色样式。

    android studio实现简单的计算器功能

    1、本地准备好图片,复制它,粘贴进mipmap(drawable)文件夹。 2、在activity_main.xml里添加下面代码,注意添加位置。 3、完成,效果图: content_main.xml文件(页面布局,content_main.xml代码包含在activity...

    三种方式自定义SeekBar样式

    三种不同的方式自定义SeekBar样式,其中的资源文件根据自己的开发软件可以修改的,如as中用的mipmap较多,eclipse中用的drawable较多。

    Android实现平铺图片效果

    最近开发App,美工设计了一个...(1)在drawable中的drawable文件中定义平铺的Bitmap <?xml version=1.0 encoding=utf-8?> android:src=@mipmap/ic_border_cupons_left android:tileMode=repeat > </bitma

Global site tag (gtag.js) - Google Analytics