本文介绍了绘制给定一组点在地图上Overylay(Android 2.1的)空的多边形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经设置了 N 点,我想提请使用这些点 n边多边形。
I've set of n points and I want to draw a n-sided polygon using these points.
我试图用android.graphics.path(请参见下文)。
I tried using android.graphics.path (please see below).
Path path = new Path(); Vertex currVtx; for (int j = 0; j < vertices.size(); j++) { currVtx = vertices.get(j); if (!currVtx.hasLatLong()) continue; Point currentScreenPoint = getScreenPointFromGeoPoint( currVtx, mapview); if (j == 0) path.moveTo(currentScreenPoint.x, currentScreenPoint.y); // vertex. else path.lineTo(currentScreenPoint.x, currentScreenPoint.y); }目前,我得到一个固体(填充画布的颜色)的多边形与此code。有没有一种方法,我可以得到一个未填充的多边形。有一个替代 android.graphics.Path
Currently I'm getting a solid (filled with the color of the canvas) polygon with this code. Is there a way that I can get an unfilled polygon. There is an alternative to android.graphics.Path
感谢。
推荐答案定义绘制对象:
Paint mPaint = new Paint(); mPaint.setStrokeWidth(2); //2 pixel line width mPaint.setColor(0xFF097286); //tealish with no transparency mPaint.setStyle(Paint.Style.STROKE); //stroked, aka a line with no fill mPaint.setAntiAlias(true); // no jagged edges, etc.
然后绘制路径有:
Then draw the path with:
yourCanvas.drawPath(path,mPaint);您可以看一下油漆文档,但也有选项吨来控制它的绘制。
You can look up the paint documentation but there are tons of options to control how its drawn.
更多推荐
绘制给定一组点在地图上Overylay(Android 2.1的)空的多边形
发布评论