安卓OverlayItem.setMarker():更改标记一个项目 [英] Android OverlayItem.setMarker(): Change the marker for one item
本文介绍了安卓OverlayItem.setMarker():更改标记一个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
试图从覆盖项目更改标记我注意到setMarker(),使该项目不可见。这里的code样本。
//创建新的标记
可绘制图标= this.getResources()getDrawable(R.drawable.marker)。
//设置新的标记,以覆盖
overlayItem.setMarker(图标);
解决方案
一个矩形边框必须为可绘制对象指定的:
//创建新的标记
可绘制图标= this.getResources()getDrawable(R.drawable.marker)。
//设置边界的绘制
icon.setBounds(
0 - icon.getIntrinsicWidth()/ 2,0 - icon.getIntrinsicHeight(),
icon.getIntrinsicWidth()/ 2,0);
//设置新的标记,以覆盖
overlayItem.setMarker(图标);
Trying to change the marker from an overlay item I noticed the setMarker() makes the item not visible. Here's the code sample.
//Create new marker
Drawable icon = this.getResources().getDrawable(R.drawable.marker);
//Set the new marker to the overlay
overlayItem.setMarker(icon);
解决方案
A bounding rectangle needs to be specified for the Drawable:
//Create new marker
Drawable icon = this.getResources().getDrawable(R.drawable.marker);
//Set the bounding for the drawable
icon.setBounds(
0 - icon.getIntrinsicWidth() / 2, 0 - icon.getIntrinsicHeight(),
icon.getIntrinsicWidth() / 2, 0);
//Set the new marker to the overlay
overlayItem.setMarker(icon);
这篇关于安卓OverlayItem.setMarker():更改标记一个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文