本文介绍了为什么getEdgeFlags()始终返回0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要检测onTouchEvent功能的触摸边对我的看法,但getEdgeFlags()总是在我歌Nexus S 4.1.1返回0,任何人都可以帮我吗?感谢提前。

  @覆盖
公共布尔onTouchEvent(MotionEvent事件){
    INT edgeFlags = event.getEdgeFlags();
    // edgeFlags送花儿给人0!
    开关(edgeFlags){
    案例MotionEvent.EDGE_LEFT:
        Log.i(标签,EDGE_LEFT);
        打破;
    案例MotionEvent.EDGE_RIGHT:
        Log.i(标签,EDGE_RIGHT);
        打破;
    案例MotionEvent.EDGE_TOP:
        Log.i(标签,EDGE_TOP);
        打破;
    案例MotionEvent.EDGE_BOTTOM:
        Log.i(标签,EDGE_BOTTOM);
        打破;
    默认:
        Log.i(标签,+ edgeFlags);
        打破;
    }
返回super.onTouchEvent(事件);
}


解决方案

我解决了添加四个按钮的问题触发四向!

I want to detect the touch edge in onTouchEvent function for my view, but getEdgeFlags() always return 0 in my Nexus S 4.1.1, anyone can help me? thanks advance.

@Override
public boolean onTouchEvent(MotionEvent event) {
    int edgeFlags = event.getEdgeFlags();
    //edgeFlags alway 0!
    switch (edgeFlags) {
    case MotionEvent.EDGE_LEFT:
        Log.i("tag", "EDGE_LEFT");
        break;
    case MotionEvent.EDGE_RIGHT:
        Log.i("tag", "EDGE_RIGHT");
        break;
    case MotionEvent.EDGE_TOP:
        Log.i("tag", "EDGE_TOP");
        break;
    case MotionEvent.EDGE_BOTTOM:
        Log.i("tag", "EDGE_BOTTOM");
        break;
    default:
        Log.i("tag", "" + edgeFlags);
        break;
    }
return super.onTouchEvent(event);
}
解决方案

I solved the problem with add four button to trigger four direction!

这篇关于为什么getEdgeFlags()始终返回0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-16 10:15