Android Studio中mipmap目录和drawable目录有什么区别

使用Android Studio开发时发现有2个目录可以放置图片: mipmap vs drawable,那么他们有什么区别呢?该选择哪个呢?

这里网罗各位大神的答案,共同学习:

答案1:

图片还是放在drawable文件夹下吧,mipmap只放launcher icons就好了。
Google官方有介绍:Managing Projects Overview
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


答案2:

Mipmaps早在Android2.2+就可以用了,但是直到4.3 google才强烈建议使用。把图片放到mipmaps可以提高系统渲染图片的速度,提高图片质量,减少GPU压力。so,do it


答案3:

我也想问这个问题。。。
经过我的研究,我认为 mipmap 支持多尺度缩放效果很好,比如一个 200*200 的图片缩放,如果我们使用 mipmap 那么系统会根据当前缩放范围选择 mipmap 里面恰当的图片,而不是想 drawable 目录下是根据当前设备的屏幕密度选择恰当的图片。如果一个 imageview 有缩放动画,使用 drawable 下的图片,会一直使用一张,来缩放图片实现 imageview 缩放动画,如果使用 mipmap 会根据缩放程度自动选择比当前分辨率大而又最接近当前分辨率的图片来做缩放处理,这样就实现了 google 官方文档中描述的更好视觉效果,更高效率的目的。这也和 mipmap 这个技术的本身含义吻合,除非 google 乱取名字。而 google 文档里面说 laucher icon 使用 mipmap 我认为是因为 laucher icon 在 laucher app 里面可能有动画,或者有的 laucher app 使用的 laucher icon 分辨率比 google 规定的大,导致使用 drawable 下面的图片会放大,而显示效果不好。


总结:

保守点跟着官方文档走:普通图片放drawable,icon图标放mipmap。既然mipmap自适应缩放效果好,那就把一些动画的图片也放进去吧。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

拭心

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值