您的位置:首页 > 移动开发 > Android开发

Android MapView 实现双击自动扩大地图

2011-05-20 15:36 417 查看
自定义MapView类,重写其onInterceptTouchEvent方法。

代码如下:

public class MyMapView extends MapView {

private long lastTouchTime = -1;

public MyMapView(Context context, AttributeSet attrs) {

super(context, attrs);

// TODO Auto-generated constructor stub

}

@Override

public boolean onInterceptTouchEvent(MotionEvent ev) {

// TODO Auto-generated method stub

if (ev.getAction() == MotionEvent.ACTION_DOWN) {

long thisTime = System.currentTimeMillis();

if (thisTime - lastTouchTime < 250) {

this.getController().zoomInFixing((int) ev.getX(), (int) ev.getY());

lastTouchTime = -1;

}else{

lastTouchTime = thisTime;

}

}

return super.onInterceptTouchEvent(ev);

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐