以下是我在Android上的Google地图上绘制圆圈的代码。它对我来说很好。
问题陈述: -
目前,在谷歌地图上绘制的圆圈非常暗。我需要制作我目前所拥有的那个圈little bit light with the same color
。通过调整油漆或颜色中的一些参数,可以使圆圈变得有点光吗?它在中心部分更暗,不知道为什么。我只需要在我目前所有的四个圆圈中都很清楚。
class MapOverlay extends Overlay {
private GeoPoint pointToDraw;
int[] imageNames=new int[6];
private Point mScreenPoints;
private Bitmap mBitmap;
private Paint mCirclePaint;
public MapOverlay(GPSLocationListener gpsLocationListener, int currentUser) {
imageNames[0]=currentUser;
mCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mCirclePaint.setColor(0x30000000);
mCirclePaint.setStyle(Style.FILL_AND_STROKE);
mBitmap = BitmapFactory.decodeResource(getResources(),imageNames[0]);
mScreenPoints = new Point();
}
public void setPointToDraw(GeoPoint point) {
pointToDraw = point;
}
public GeoPoint getPointToDraw() {
return pointToDraw;
}
@Override
public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
super.draw(canvas, mapView, shadow);
if (pointToDraw == null) {
return true;
}
mScreenPoints = mapView.getProjection().toPixels(pointToDraw, mScreenPoints);
int totalCircle=5;
int radius=40;
int centerimagesize=35;
for (int i = 1; i <= totalCircle; i ++) {
canvas.drawCircle(mScreenPoints.x,mScreenPoints.y, i*radius, mCirclePaint);
}
canvas.drawBitmap(mBitmap, (mScreenPoints.x-(centerimagesize/2)),(mScreenPoints.y-(centerimagesize/2)), null);
super.draw(canvas,mapView,shadow);
return true;
}
}
我圈子的快照目前为 -
任何建议都会有很大帮助。
答案 0 :(得分:2)
<强>问题强>
它在中心变暗的原因是因为你画了四个圆圈,一个在另一个圆圈上。当您绘制第二个圆时,与两者共同的部分被涂成两次,因此它变得更暗。当你画出一个圆圈时,它会变得更暗......
<强>解决方案强>
如果您希望所有圈子具有相同的颜色,则应对所有圈子使用Style.STROKE
,但较大的圈子除外,使用Style.FILL_AND_STROKE
。因此,您只绘制小圆圈的线条,并在绘制大圆圈时填充所有区域。
<强>代码强>
mCirclePaint.setStyle(Style.STROKE);
for (int i = 1; i <= totalCircle-1; i ++) {
canvas.drawCircle(mScreenPoints.x,mScreenPoints.y, i*radius, mCirclePaint);
}
mCirclePaint.setStyle(Style.FILL_AND_STROKE);
canvas.drawCircle(mScreenPoints.x,mScreenPoints.y, totalCircle*radius, mCirclePaint);
此致