竹山一叶

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

Android上创建工程,会默认创建mipmap文件夹。之前在Eclipse上创建的是drawable的文件夹。那么这两个有什么区别呢? 
问题: 
I’m working with android studio 1.1 Preview 1 
我使用android studio 1.1 Preview 1版本工作。 
And I noticed that when I create a new project I’m getting next hierarchy: 
我注意到当创建新的工程时,得到了下面的目录层级: 
这里写图片描述 
mipmap folders for diffrent DPIs, No more diffrent DPIs drawable folders. 
4个不同分辨率的mipmap文件夹,与不同DPI的drawable文件夹没啥区别。 
Should I put all my resources in the mipmap folders, or just the app icon? 
我应该把所有资源都放到mipmap文件夹么?或者只放应用的图标? 
答案: 
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. 
mipmap文件夹只放应用图标。其他需要使用的drawable资源象之前一样放到对应的drawable文件夹。 
According to this Google blogpost: 
根据这篇google的博文: 
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. 
应用的启动图标最好放到mipmap文件夹(不是drawable文件夹),因为它们用在不同分辨率的设备上。 
When referencing the mipmap- folders ensure you are using the following reference: 
当引用mipmap文件夹的资源时,需要使用下面的方式:

android:icon="@mipmap/ic_launcher"

结论: 

mipmap仅仅用于应用启动图标,可以根据不同分辨率进行优化。其他的图标资源,还是要放到drawable文件夹中。

Android 官方解释[3]:

Note: You should place all launcher icons in the res/mipmap-[density]/ folders, rather than drawable/ folders to ensure launcher apps use the best resolution icon. 
注意:你应当将虽有启动图标放到res/mipmap-[density]/文件夹中,而不是drawable/文件夹,来确保启动图片使用最好的分辨率图标。

参考[1]:http://stackoverflow.com/questions/28065267/mipmap-vs-drawable-folders 
参考[2]:http://stackoverflow.com/questions/23935810/mipmap-drawables-for-icons 
参考[3]:https://developer.android.com/training/multiscreen/screendensities.html






posted on 2017-05-19 15:35  竹山一叶  阅读(1509)  评论(0编辑  收藏  举报