0

我正在创建 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);
}

它只是画圈。我想在方形图像周围绘制边框。

4

1 回答 1

0

您正在为绘制矩形传递相同的值,即(左、上、右、下)它应该是

drawRect (float left, float top, float right, float bottom, Paint paint)

参考API 文档

你正在传递 canvas.drawRect(left.x,left.y, left.x, left.y , paint); 右下角

于 2012-11-08T10:39:20.690 回答