Android mipmap和drawable

  有很多朋友在android studio下生成项目时会发现有mipmap文件夹,而相对应的drawable不见了,于是开始发大招,百度,google,多数得到的回馈是mipmap优化了渲染性能,建议用mipmap取代drawable,这些纯属误导,还是把人家官方的描述拿出来把,这样权威些,原文地址:http://developer.android.com/tools/projects/index.html#mipmap

 部分描述:

Different home screen launcher apps on different devices show app launcher icons at variousresolutions. When app resource optimization techniques remove resources for unused screen densities, launcher icons can wind up looking fuzzy because the launcher app has to upscalea lower-resolution icon for display. To avoid these display issues, apps should use the mipmap/ resource folders for launcher icons. The Android system preserves these resources regardless of density stripping, and ensures that launcher apps can pick icons with the best resolution for display.

Make sure launcher apps show a high-resolution icon for your app by moving all densities of yourlauncher icons to density-specific res/mipmap/ folders(for example res/mipmap-mdpi/ and res/mipmap-xxxhdpi/). The mipmap/ folders replace the drawable/ folders for launcher icons. Forxxhpdi launcher icons, be sure to add the higher resolution xxxhdpi versions of theicons to enhance the visual experience of the icons on higher resolution device

就不详细翻译了,大致意思呢就是mipmap是专门放置启动图标的,是由于应用的资源优化技术会删除没有使用的相对应屏幕密度的drawable的图片资源。

如果手机介于两个密度之间就可能会导致系统留下不合适的图片进行缩放等操作而导致图标模糊。而使用mipmap,android系统会始终保留这些资源使得系统能够挑选更好分辨率的图标进行显示。

在开发者关于屏幕适配的文章中,还有一句话更能说明mipmap的终极用途

Note: The mipmap-xxxhdpiqualifier is necessary only to provide a launcher icon that can appear larger than usual on anxxhdpi device. You do not need to provide xxxhdpi assets for all your app's images.

“only” fro launcher icon,也可以打消很多人想要把其他资源也放到mipmap下的疑问

经过自己的测试,将其他图片资源放入mipmap也可以,除了.9图片,还有引入的时候要用@mipmap或者R.mipmap.

在这里我还有个“?”,按照第一段开发者里的描述,如果把资源都放到mipmap中,系统会保留所有的资源而不去删除会不会导致性能等问题?如果有知道的大牛还请指教?




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值