android:MotionEvent

mTouchListener = new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub float x = event.getXPrecision()*event.getX()+event.getX(); float y = event.getYPrecision()*event.getY()+event.getY(); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: break; case MotionEvent.ACTION_MOVE: mTouchTimes++; if (mTouchTimes > TOUCH_TIMES) { // 根据方向计算角度 if (mCurrentOrientation==DeviceOrientation.Landscape) { mAngle = Math.toDegrees(Math.atan2(y - 480 / 2, x))+90; } else { mAngle = -Math.toDegrees(Math.atan2(y - 480 / 2, 320-x))+90; } Log.w("angle", "mangle:"+mAngle); } break; case MotionEvent.ACTION_UP: if (mTouchTimes > TOUCH_TIMES) { } else { } mTouchTimes = 0; break; default: break; } return true; } }; mView.setOnTouchListener(mTouchListener);

你可能感兴趣的:(android,UP,float)