Android进阶:在地图MapView中画一个图标并带阴影效果

看看效果先

 

自己调试了一下午终于搞定了这里来整理一下吧 直接上代码吧

 

 

 

刚开始做的时候老是出现图片本身和阴影的颜色都被过滤了 但是我仅仅是调用了drawable1 的颜色过滤方法

 

后来发现了资源状态共享的问题

 

下面了解一下 mutate()方法

 

Make this drawable mutable. This operation cannot be reversed. A mutable drawable is guaranteed to not share its state with any other drawable. This is especially useful when you need to modify properties of drawables loaded from resources. By default, all drawables instances loaded from the same resource share a common state; if you modify the state of one instance, all the other instances will receive the same modification. Calling this method on a mutable Drawable will have no effect

 

大概就是改变当前资源状态 变为活动的可变的 因为 drawable资源不管加载几次 它的状态是共享的,所以在改变一个对象的状态的时候其它的引用到该资源的对象也会改变 所以让drawable1调用该方法 锁定这个对象调用的资源状态

 

下面clearColorFilter()这个方法也是起到同样的作用 可以解决这个问题

 

反正解决了就行了。。具体有什么不同就不深究了

 

还有注意的就是 setBounds() 两个设置的不同, 因为drawable1还要经过位移

 

中间还有个方法

 

 

就是移动位置到点坐标的正上方 图标嘛 就是这个坐标的具体位置的解释嘛 不能把它给覆盖了

 

 

 

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值