Android Studio的图片到底是放在drawable还是mipmap呢

从事Android 开发的工程师们一直以为都在讨论一个问题,那就是图片到底应该放在android Studio软件drawable文件夹下,还是应该放在mipmap下?今天把网络上出现的讨论做一个小小的梳理,如果哪里不正确还请指正,文章中会引用一些其他博客的字段,在文章的末尾都会把转载的地址附上。


    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.

icons 放在mipmap下,而且mipmap只放mipmap。


Mipmapping for drawables
    Using a mipmap as the source for your bitmap or drawable is a simple way to provide a quality image and various image scales, which can be particularly useful if you expect your image to be scaled during an animation.
    Android 4.2 (API level 17) added support for mipmaps in the Bitmap class—Android swaps the mip images in your Bitmap when you've supplied a mipmap source and have enabled setHasMipMap(). Now in Android 4.3, you can enable mipmaps for a BitmapDrawable object as well, by providing a mipmap asset and setting the android:mipMap attribute in a bitmap resource file or by calling hasMipMap().


那图片到底应该哪个文件夹下呢?有问题找stackoverflow 。

我们可以看到这样的提问,问题是: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文件夹。


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. 




综上:图片应该放在drawable文件夹下,而mipmap文件夹只适合放app icons ,之前Android Studio 1.1版本的时候app icons上上传几个不同分辨率的图片,而现在Android Studio 2.1.2 已经把mipmap文件夹默认分为了不同分辨率的文件夹,方便适配。


  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 154,579评论 23 678
  • 屏幕适配 屏幕适配的概念 碎片化既是 Android 的优势和弱点,也是开发者们头疼的问题,同时也为 Androi...
    s酸菜阅读 7,292评论 9 56
  • 昨天的“男人不坏女人不爱”那一节里你是否能联想到商业世界的“从众心理”。 给你举个例子,高中时听说别班有个美女,特...
    Xio聚兽阅读 72评论 0 0
  • 今天的工作量突然剧增,猝不及防。因为平时没有做好应对突发事件的准备,搞得自己焦头烂额。本来明天周六可以休息的,这下...
    任雨点阅读 49评论 0 0
  • 日自卫队海外演练 约130人参加金色眼镜蛇训练 日本公然介入台海冲突急于向美表忠心 信息来源新闻联播
    白语金言阅读 93评论 0 1