【发布时间】:2016-01-13 18:02:59
【问题描述】:
在 Bitmap 和 canvas 的帮助下,我的 Google Map App 中有一个使用过的自定义标记。当我在 android 版本 5.1 或除 4.4 以外的任何其他设备上运行标记时,标记上的图像会很好。
我确定这不是版本问题。但我很困惑,无法弄清楚我在哪里做错了。请帮我找到它。
自定义标记(位图)代码:
Bitmap.Config conf = Bitmap.Config.ARGB_8888;
Bitmap bmp = Bitmap.createBitmap(128, 128, conf);
Canvas canvas1 = new Canvas(bmp);
canvas1.drawBitmap(BitmapFactory.decodeResource(getResources(),
R.drawable.map_markers_green), 0, 0, color);
canvas1.drawText(String.valueOf(a).toUpperCase(), 56, 53, color);
googleMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromBitmap(bmp))
// Specifies the anchor to be at a particular point in the marker image.
.anchor(0.5f, 1));
在设备上工作正常的标记图像:
在不同设备上剪切的相同标记图像:
【问题讨论】:
标签: android google-maps android-canvas android-bitmap