天天看点

mipmap和drawable文件夹的区别

同步发布在: http://snowdream.github.io/blog/2016/03/02/mipmap-vs-drawable-folders/

现在,通过android studio创建android工程,默认会创建mipmap文件夹,而不是以前的drawable文件夹。那么mipmap和drawable文件夹到底有什么区别呢?

mipmap文件夹下的图标会通过mipmap纹理技术进行优化。关于mipmap纹理技术的介绍,请参考:mipmap纹理技术简介

经过查询官方和第三方资料,得出结论:

mipmap文件夹下,仅仅建议放启动图标/app launcher icons,也就是应用安装后,会显示在桌面的那个图标。而其他的图片资源等,还是按照以前方式,放在drawable文件夹下。

下面再详细阐述下,得出以上结论的依据:

1.google官方关于mipmap和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. 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.

2.stackoverflow上关于mipmap和drawable的区别

the mipmap folders are for placing your app icons in only. any other drawable assets you use should be placed in the relevant drawable folders as before.

以ic_launcher为例。

1.放在mipmap文件夹下时,引用方式如下:

2.放在drawable文件夹下时,引用方式如下:

mipmap纹理技术简介

mipmap vs drawable folders

google官方关于mipmap和drawable的定位