Issue
I am currently drawing lines on a MapView based on different GeoPoints to indicate sectors. With the following code (this is within an overlay):
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow)
{
for(Polygon polygonTemp : polygonList)
{
Path p = new Path();
Projection projection = mapView.getProjection();
boolean firstTime = true;
for(GeoPoint geoPoint : polygonTemp.getGeoPointList())
{
Point drawPoint = new Point();
projection.toPixels(geoPoint, drawPoint);
if(firstTime)
{
p.moveTo(drawPoint.x, drawPoint.y);
firstTime = false;
}
else
{
p.lineTo(drawPoint.x, drawPoint.y);
}
}
p.setFillType(Path.FillType.EVEN_ODD);
Paint polyPaint = new Paint();
polyPaint.setStrokeWidth(1);
polyPaint.setStyle(Paint.Style.FILL_AND_STROKE);
polyPaint.setAntiAlias(true);
polyPaint.setColor(Color.parseColor(polygonTemp.getColor()));
canvas.drawPath(p, polyPaint);
firstTime = true;
}
super.draw(canvas, mapView, shadow);
}
The problem is, I want them to be filled with some degree of transparency, so I can still see the map under the filled sectors. I tried to set polyPaint.setAlpha(), even to 255 (which should be completely transparent) and it doesn't do anything, it's completely opague.
Anyone knows what I'm doing wrong?
Solution
I don't see where you are setting the alpha. Regardless 255 is not transparent, it is opaque.
FYI, I am doing identical things (drawing paths on map overlays) and this works fine for drawing a 50% opaque, red line:
mPaint.setColor(Color.parseColor ("#88ff0000"));
Answered By - rob
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.