前言:个人在之前的项目开发中,一直以为mipmap是为了取代drawable,所以把项目的切图都是放在mipmap中,一些shape,selector,.9.png等文件放在drawable中,程序也没有出现什么问题。某一天听说mipmap其实只是放APP的icon图标,其他的图片等文件还是跟之前eclipse一样,都是放在drawable中。那到底是怎么放的,我从网上搜索了一下:
这个是google官方对drawable和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.
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的icon图标的。虽然一些切图放在mipmap上,项目运行也是没有错误的。但是作为一个严谨的开发者,我们需要遵守规范。正所谓 无规矩不成方圆 。
所以我们得出的结论是:mipmap只是放app的icon图标,其他的还是放在老地方—>drawable中。
tips:这边我再对这个mipmap做个拓展,对图标的尺寸的进行说明:
mipmap-mdpi/ic_launcher.png (48x48 pixels)
mipmap-hdpi/ic_launcher.png (72x72)
mipmap-xhdpi/ic_launcher.png (96x96)
mipmap-xxhdpi/ic_launcher.png (144x144)
mipmap-xxxhdpi/ic_launcher.png (192x192)