Android的获取图形页面上一扔停止动画 [英] Android Get Mapview on Fling stopped animating

查看:148
本文介绍了Android的获取图形页面上一扔停止动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要限制我的用户可以在图形页面导航到该地区(除非他们会得到一个空白屏幕!)。
我创建了扩展的MapView类,并覆盖了onTouchEvent。
我检测行动ACTION_UP这里检查COORDS和repostioning地图,如果我不得不这样做。一切工作正常,直到用户甩地图。我可以检测向上,并在该点上的画面的坐标,但地图仍移动,所以我检测坐标不在正确的。

I need to limit the area my users can navigate to in the mapview (unless they'll get a blank screen!). I have created a class that extends the mapview and overridden the onTouchEvent. I am detecting the action "ACTION_UP" and checking the coords here and repostioning the map if I have to. Everything works fine until the user "flings" the map. I can detect the "Up" and the coordinates of the screen at that point, but the map is still moving so the coordinates I detect aren't the correct ones.

我需要知道屏幕上的位置时,它的不动了!

I need to know the screen position when it's stopped moving!

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        if (ev.getAction() == MotionEvent.ACTION_UP ) {
//get coords of screen corners and calculate if the map is still in view.
}

我一直在寻找的答案,这相当数量的时间,但很多人都在问这个问题,但似乎没有被周围的任何解决方案?

I have been looking for a fair amount of time for the answer to this but lots of people are asking the question, but there don't appear to be any solutions around?

有没有人成功地做到这一点?

Has anyone managed to do this?

贝克斯

推荐答案

我有同样的问题。你的做法是好的,只是需要捉对另一个地方的事件。您可以覆盖的MapView类的DispatchTouchEvent的方法(或采取使用MapFragment类似的方法),而你把它跳过MotionEvent.ACTION_UP事件:

I had the same problem. Your approach is good, just need to catch the event on another place. You can override "DispatchTouchEvent" method of MapView class (or take similar approach using MapFragment), and there you make it skip MotionEvent.ACTION_UP event:

if (ev.getAction() == MotionEvent.ACTION_UP ) {
   return false;
}

这篇关于Android的获取图形页面上一扔停止动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆