class MyOnTouchListener implements OnTouchListener{ @Override public boolean onTouch(View arg0, MotionEvent event) { //上是 1 左是0下是2右是3 float x = event.getX() / v.getWidth(); float y = event.getY() / v.getHeight(); // Direction will be [0,1,2,3] depending on quadrant int direction = 0; direction = (x > y) ? 1 : 0; direction |= (x > 1 - y) ? 2 : 0; // showMsg(""+direction); return false; } }