2013-06-12 4 views
1

제 질문이 너무 단순한 경우 사과하십시오.사용자 위치 주변에 다른 색의 테두리가있는 원이 필요합니다.

지도에서 사용자 위치를 표시하는 Android 앱을 개발 중입니다. 사용자 지점 주위에 원을 표시하고 있습니다. ItemizedOverlay에서 이것에 대한

내 코드는 다음과 같습니다 위의 코드를 사용하여

public void setGeoPoints(GeoPoint theGeoPoints, int theCircleRadius) 
    { 
     this.itsGeoPoints = theGeoPoints; 
     itsPaint = new Paint(); 
     itsPaint.setARGB(10, 0, 0, 205); 
     this.itsCircleRadius = theCircleRadius; 
    } 

    @Override 
    public void draw(Canvas theCanvas, MapView theMapView, boolean shadow) 
    { 
     super.draw(theCanvas, theMapView, shadow); 
     Point pt = theMapView.getProjection().toPixels(itsGeoPoints, null); 
     float projectedRadius = theMapView.getProjection().metersToEquatorPixels(itsCircleRadius); 
     theCanvas.drawCircle(pt.x, pt.y, projectedRadius, itsPaint); 
    } 

, 내가 완벽하게 사용자의 위치 주위에 파란색 원을 얻을.

이제 다른 색상으로 원의 경계선이 있어야합니다. 즉, 굵은 테두리가있는 원 (다른 색)입니다.

이 문제에 대한 도움이 필요합니다.

감사합니다.

답변

1

Paint.setStyle 및 다른 색을 사용하여 STROKE 스타일로 설정된 별도의 Paint 개체를 만들어야합니다.

drawCircle에이 새로운 Paint으로 다시 전화하면됩니다.

+0

감사합니다. MaciejGórski! –

0

감사합니다. MaciejGórski!

public void setGeoPoints(GeoPoint theGeoPoints, int theCircleRadius) 
    { 
     this.itsGeoPoints = theGeoPoints; 

     itsPaint1 = new Paint(); 
     itsPaint1.setARGB(150, 0, 0, 255); 
     itsPaint1.setStyle(Style.STROKE); 

     itsPaint2 = new Paint(); 
     itsPaint2.setStyle(Style.FILL); 
     itsPaint2.setARGB(5, 0, 0, 200); 
     this.itsCircleRadius = theCircleRadius; 
    } 

    @Override 
    public void draw(Canvas theCanvas, MapView theMapView, boolean shadow) 
    { 
     super.draw(theCanvas, theMapView, shadow); 

     Point pt = theMapView.getProjection().toPixels(itsGeoPoints, null); 
     float projectedRadius = theMapView.getProjection().metersToEquatorPixels(itsCircleRadius); 

     theCanvas.drawCircle(pt.x, pt.y, projectedRadius, itsPaint1); 
     theCanvas.drawCircle(pt.x, pt.y, projectedRadius, itsPaint2); 
    }