mipmap和drawable文件夹的区别

博客源址:http://www.chinaz.com/news/2016/0308/510428.shtml

现在,通过Android Studio创建Android工程,默认会创建mipmap文件夹,而不是以前的drawable文件夹。那么mipmap和drawable文件夹到底有什么区别呢? 

定位不同

mipmap文件夹下的图标会通过Mipmap纹理技术进行优化。关于Mipmap纹理技术的介绍,请参考:Mipmap纹理技术简介(http://blog.csdn.net/linber214/article/details/3342051/?spm=5176.blog7416.yqblogcon1.7.l21Y7w )

经过查询官方和第三方资料,得出结论:

mipmap文件夹下,仅仅建议放启动图标/app launcher icons,也就是应用安装后,会显示在桌面的那个图标。而其他的图片资源等,还是按照以前方式,放在drawable文件夹下。

下面再详细阐述下,得出以上结论的依据:

1.google官方关于mipmap和drawable的定位

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.stackoverflow上关于mipmap和drawable的区别

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.

用法不同

以ic_launcher为例。

1.放在mipmap文件夹下时,引用方式如下:

android:icon="@mipmap/ic_launcher"R.mipmap.ic_launcher

2.放在drawable文件夹下时,引用方式如下:

android:icon="@drawable/ic_launcher"R.drawable.ic_launcher 参考

Mipmap纹理技术简介(http://blog.csdn.net/linber214/article/details/3342051/?spm=5176.blog7416.yqblogcon1.10.ajK2su )

mipmap vs drawable folders(http://stackoverflow.com/questions/28065267/mipmap-vs-drawable-folders/28065664#28065664 )

google官方关于mipmap和drawable的定位(http://developer.android.com/intl/ko/tools/projects/index.html?spm=5176.blog7416.yqblogcon1.12.dzUBKW )

关于阿里百川

阿里百川(baichuan.taobao.com)是阿里巴巴集团“云”+“端”的核心战略是阿里巴巴集团无线开放平台,基于世界级的后端服务和成熟的商业组件,通过“技术、商业及大数据”的开放,为移动创业者提供可快速搭建App、商业化APP并提升用户体验的解决方案;同时提供多元化的创业服务-物理空间、孵化运营、创业投资等,为移动创业者提供全面保障。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值