我正在创建MapView应用程序,我必须在其中显示其URL来自服务器的商业徽标,带有黑色边框。 我在MapView上显示了商业标识,但是我可以在商业标识周围绘制边框的方式和位置。 我见过绘制圆圈的代码:
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setStrokeWidth(2.0f);
double latitude = 37.819586;
double longitude = -122.478532;
Projection projection = mapView.getProjection();
GeoPoint leftGeo = new GeoPoint((int) (latitude * 1e6),
(int) (longitude * 1e6));
Point left = new Point();
projection.toPixels(leftGeo, left);
paint.setColor(Color.parseColor("#00CCFF"));
paint.setStyle(Style.FILL);
canvas.drawCircle(left.x, left.y, 9, paint);
paint.setColor(Color.parseColor("#003399"));
paint.setStyle(Style.STROKE);
canvas.drawCircle(left.x, left.y, 19, paint);
canvas.drawRect(left.x,left.y,left.x, left.y, paint);
super.draw(canvas, mapView, false);
}
这只是绘制圆圈。我想在方形图像周围绘制边框。
答案 0 :(得分:0)
您正在为绘制rect传递相同的值,即(左,上,右,下)它应该是
drawRect (float left, float top, float right, float bottom, Paint paint)
参考API docs
你正在传递canvas.drawRect(left.x,left.y, left.x,left.y ,paint);到右边和底部