Android Studio(AS)-->drawable
2017-04-27 本文已影响86人
angcyo
阅读前提: 你需要提前了解 drawable 和 mipmap 是什么;
使用Android Studio IDE, 新建Android项目的时候,程序(APP)启动图标ic_launcher.png,没有在之前的老地方(drawable目录),而是出现在mipmap目录结构下;
为了一探究竟,翻阅了Android 开发者官网(http://developer.android.com);
找到以下解释:
main/res/
Contains application resources, such as drawable files, layout files, and string values in the following directories. See Application Resources for more information.
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.
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.
恕我英语能力不足,无法翻译;
原文地址:http://developer.android.com/intl/zh-cn/tools/projects/index.html#ApplicationModules
勉强使用工具翻译,大致内容如下:
drawable/
用于图片文件(PNG, JPEG , or GIF), .9图片文件 和 XML文件;
mipmap/
用于App Launcher图标;
其他官网相关阅读地址:
http://developer.android.com/intl/zh-cn/tools/projects/index.html#mipmap
http://developer.android.com/intl/zh-cn/guide/practices/screens_support.html#support
补充阅读:
两者使用上没有任何区别,你把它当drawable用就好了。唯一的区别就是用mipmap系统会在缩放上提供一定的性能优化。
比如:
Nexus 6 有 493 ppi,它刚好在 xxhdpi和xxxhdpi之间,所以显示的时候需要对xxxhdpi的资源进行缩小,如果你用了mipmap-xxxhdpi,那么这里会对sclae有一个优化,性能更好,占用内存更少。所以现在官方推荐使用mipmap.
至此: 文章就结束了,如有疑问: QQ群:274306954 欢迎您的加入.