2012-05-03 24 views
0

我会尽力将我的问题分解为一个简单的例子。我试图画 一个圆形,它完全停留在视图的中间。为此,我 用下面的代码在我覆盖的绘制方法:Android:MapView - getMapCenter()不准确?


GeoPoint mapCenter = mapView.getMapCenter(); 
Projection projection = mapView.getProjection(); 

int centerLat = mapCenter.getLatitudeE6(); 
int centerLong = mapCenter.getLongitudeE6(); 

Point pCircleCenter = new Point(); 

GeoPoint circleCenter = new GeoPoint(centerLat, centerLong); 

projection.toPixels(circleCenter, pCircleCenter); 

canvas.drawCircle(pCircleCenter.x, pCircleCenter.y, 30, testPaint); 

当我运行代码的圈子恰恰是在屏幕的中间。 它也停留在中间,当我滚动垂直,但是当我滚动 水平圆圈在滚动方向略有移动。 圈子在一些卷轴而不是 停留在中间后完全不在位置。

(这是我的问题,只是一个简化版本,但我需要得到 中期这种方式,而不是仅仅坚持它的取景当中。)

回答

0

一种选择是只添加一个ImageView通过布局文件。