在Map Overylay(Android 2.1)上给出一组点绘制空多边形

Sou*_*nta 2 graphics android polygon path android-sdk-2.1

我有一组n点,我想n-sided用这些点绘制一个多边形.

我尝试使用android.graphics.path(请参见下文).

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);

}
Run Code Online (Sandbox Code Playgroud)

目前,我正在使用此代码获得一个实体(填充了画布的颜色)多边形.有没有办法可以得到一个未填充的多边形.有另一种选择android.graphics.Path

谢谢.

Mar*_*ark 8

定义Paint对象:

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.
Run Code Online (Sandbox Code Playgroud)

然后绘制路径:

yourCanvas.drawPath(path,mPaint);
Run Code Online (Sandbox Code Playgroud)

你可以查看油漆文档,但有很多选项可以控制它的绘制方式.