Android Studio---> darwable与mipmap的差别

    最近遇到了一个很棘手的问题,原来的项目是在eclipse中写的,迫于google的强大压力,最近把项目转到了android studio(as)下,然后在新增加功能时发现: 只要主view中包含listview, viewpager等可以滑动的控件,主view的background属性就不能用以前的背景图(全屏图片,jpg格式),不用什么事没有,一用就卡的不要不要的,网上问了好多人,都没有这个问题,后来就自己一点一点尝试,排查,终于在N多天后找到原因:

       如果背景图放在darwable文件夹下,就会狂卡;  改放在mipmap-hdpi下,问题消失!

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    为此,我特意查了google官方解释:

<pre id="recommend-content-2209489229" class="recommend-text mb-10" style="margin-top:0px; margin-bottom:10px; padding:0px; font-family:arial,'courier new',courier,宋体,monospace,'Microsoft YaHei'; white-space:pre-wrap; word-wrap:break-word; font-size:14px; color:rgb(51,51,51); line-height:24px; background-color:rgb(243,255,236)" name="code"><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(20,25,30); font-family:'Microsoft Yahei','Hiragino Sans GB',Helvetica,'Helvetica Neue',微软雅黑,Tahoma,Arial,sans-serif; font-size:14px; line-height:24.6399993896484px">drawable/</p><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(20,25,30); font-family:'Microsoft Yahei','Hiragino Sans GB',Helvetica,'Helvetica Neue',微软雅黑,Tahoma,Arial,sans-serif; font-size:14px; line-height:24.6399993896484px">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.</p><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(20,25,30); font-family:'Microsoft Yahei','Hiragino Sans GB',Helvetica,'Helvetica Neue',微软雅黑,Tahoma,Arial,sans-serif; font-size:14px; line-height:24.6399993896484px">mipmap/</p><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(20,25,30); font-family:'Microsoft Yahei','Hiragino Sans GB',Helvetica,'Helvetica Neue',微软雅黑,Tahoma,Arial,sans-serif; font-size:14px; line-height:24.6399993896484px">For app launcher icons. The <a target=_blank href="http://lib.csdn.net/base/android" class="replace_word" title="Android知识库" target="_blank" style="color:#df3434; font-weight:bold;">Android</a> 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.</p>

     上边说的很清楚所有应用图片都可以放在darwnable里,正常调用没问题 

    但是,如果你的图片比较大,或者需要适配,显然放在mipmap里更合适,因为google对这个文件夹下的图片进行了加工,提高了图片质量,提高了系统渲染图片的速度,同时还减轻了GPU的压力,使用普通图片是感受不到这种优化的,但在极限情况下这个作用就非常巨大了

    综上:google强烈推荐用mipmap不是没道理的,大图,高清力尽量都放在这里,不会吃亏,当然,这类图引用的时候也要尽量避免直接使用background,最好用image,src方式

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值