So I'm drawing this triangle in android maps using the code below in my draw method:
paint.setARGB(255, 153, 29, 29);
paint.setStyle(Paint.Style.FILL_AND_STROKE);
paint.setAntiAlias(true);
Path path = new Path();
path.moveTo(point1_returned.x, point1_returned.y);
path.lineTo(point2_returned.x, point2_returned.y);
path.moveTo(point2_returned.x, point2_returned.y);
path.lineTo(point3_returned.x, point3_returned.y);
path.moveTo(point3_returned.x, point3_returned.y);
path.lineTo(point1_returned.x, point1_returned.y);
path.close();
canvas.drawPath(path, paint);
The pointX_returned are the coordinates which I'm getting from the fields. They are basically latitudes and longitudes. The result is a nice triangle but the insider is empty and therefore I can see the map. Is there a way to fill it up somehow?
this function shows how to create a triangle from bitmap. That is, create triangular shaped cropped image. Try the code below or download demo example
The function above returns an triangular image drawn on canvas. Read more
You need remove path.moveTo after first initial.
Ok I've done it. I'm sharing this code in case someone else will need it:
Thanks for the hint Nicolas!
You probably need to do something like :
And use this color for your path, instead of your ARGB. Make sure the last point of your path ends on the first one, it makes sense also.
Tell me if it works please !
you can also use vertice :