为什么getEdgeFlags()总是返回0

时间:2012-08-14 14:57:19

标签: java android

我想在我的视图中检测onTouchEvent函数的触摸边缘,但是getEdgeFlags()总是在我的Nexus S 4.1.1中返回0,有人可以帮助我吗?谢谢你。

@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);
}

1 个答案:

答案 0 :(得分:1)

我通过添加四个按钮触发四个方向来解决问题!