Res--->mipmap初步认识

前言

问题:mipmap&drawable 为什么会存在两个放图片的地方
答案:mipmap放icon,其他图片都放在drawable下
引用了:https://segmentfault.com/a/1190000009045864

另外很多人对图片是放在mipmap下面还是drawable下面总是有疑问,对放在什么文件夹下面没有什么概念,对此官方有个解释:

Drawables may be stripped out as part of dp-specific resource optimisation. But mipmaps will not be stripped. So it's best to put app icons under mipmaps.

Here is more detail written on google documentation page:
Different home screen launcher apps on different devices show app launcher icons at various resolutions. When app resource optimization techniques remove resources for unused screen densities, launcher icons can wind up looking fuzzy because the launcher app has to upscale a lower-resolution icon for display. To avoid these display issues, apps should use the mipmap/ resource folders for launcher icons. The Android system preserves these resources regardless of density stripping, and ensures that launcher apps can pick icons with the best resolution for display.

总结下:
上面话就是想表达放在drawable的图片会对不适用真机屏幕密度的资源进行移除,
放在mipmap依然会保留下各个密度的图片,所以为了保证桌面图标的显示质量因此放在mipmap下面,其他的图标建议都放在drawable文件夹下面吧。

icon尺寸

密度 建议尺寸
mipmap-mdpi 48 * 48
mipmap-hdpi 72 * 72
mipmap-xhdpi 96 * 96
mipmap-xxhdpi 144 * 144
mipmap-xxxhdpi 192 * 192

结语

作者:知乎用户
链接:https://www.zhihu.com/question/29265243/answer/102971363
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
谷歌官方:

drawable/For bitmap files (PNG, JPEG, or GIF), 9-Patch image files, and XML files that describe Drawable shapes or Drawable objects that contain multiple states (normal, pressed, or focused). See the Drawable resource type.

翻译:drawable/用于位图文件(PNG,JPEG,或GIF),9补丁图像文件,和XML文件,描述可绘制形状或可绘制对象包含多个状态(正常,按下或聚焦)。请参阅可绘制资源类型。

mipmap/For app launcher icons. The Android system retains the resources in this folder (and density-specific folders such as mipmap-xxxhdpi) regardless of the screen resolution of the device where your app is installed. This behavior allows launcher apps to pick the best resolution icon for your app to display on the home screen. For more information about using the mipmap folders, see Managing Launcher Icons as mipmap Resources.

翻译:MIPMAP/APP启动图标。Android系统保留该文件夹中的资源(以及密度特定文件夹,如MIPMAP XXXHDPI),而不管安装应用程序的设备的屏幕分辨率。这种行为允许发射器应用程序为你的应用程序选择最佳分辨率图标来显示在主屏幕上。有关使用MIPMAP文件夹的更多信息,请参见管理启动图标作为MIPMAP资源。

个人看法

如上所述,google官方似乎更支持mipmap只放icon,但是曾经有过一次很大图放在drawable下直接加载很卡的经历,mipmap的优化效果很好。(但是规范来讲,不应该有很大的图直接被使用进来)。以后如果由更新的更改,//Todo

你可能感兴趣的:(Res--->mipmap初步认识)