Android map overly transparency has unwanted gradient
- by DavidP2190
I'm a making my first android app and for part of it I need some shaded areas over a mapview.
I've got this working so far but the when I set the alpha of the fill colour, it goes strange.
I'm not allowed to post images yet, but you can see what happens here:
http://i.imgur.com/leXmc.png
I'm not sure what causes it, but here is some code from where it gets drawn.
public boolean draw(Canvas canvas, MapView mapView, boolean shadow,
long when) {
Paint paint = new Paint();
paint.setStrokeWidth(2);
paint.setColor(android.graphics.Color.GREEN);
paint.setStyle(Paint.Style.FILL_AND_STROKE);
paint.setAlpha(25);
screenPoints = new Point[10];
Path path = new Path();
for (int x = 0; x<greenZone.length; x++){
screenPoints[x] = new Point();
mapView.getProjection().toPixels(greenZone[x], screenPoints[x]);
}
path.moveTo(screenPoints[0].x, screenPoints[0].y);
for (int x = 1; x < screenPoints.length-1; x++){
paint.setAlpha(25);
if (x<9){
path.lineTo(screenPoints[x].x, screenPoints[x].y);
canvas.drawPath(path, paint);
}
else{
path.moveTo(screenPoints[screenPoints.length-1].x, screenPoints[screenPoints.length-1].y);
path.lineTo(screenPoints[0].x, screenPoints[0].y);
canvas.drawPath(path, paint);
}
}
return true;
}
Thanks.