在Android层实现触摸屏校验
2010-05-31 14:35:00 来源:WEB开发网/ (float)device.absSize.range);
}
switch (orientation) {
case Surface.ROTATION_90:
temp = scaledX;
scaledX = scaledY;
scaledY = w-temp;
break;
case Surface.ROTATION_180:
scaledX = w-scaledX;
scaledY = h-scaledY;
break;
case Surface.ROTATION_270:
temp = scaledX;
scaledX = h-scaledY;
scaledY = temp;
break;
}
if (scaledX == 0) {
edgeFlags += MotionEvent.EDGE_LEFT;
} else if (scaledX == display.getWidth() - 1.0f) {
edgeFlags += MotionEvent.EDGE_RIGHT;
}
if (scaledY == 0) {
edgeFlags += MotionEvent.EDGE_TOP;
} else if (scaledY == display.getHeight() - 1.0f) {
edgeFlags += MotionEvent.EDGE_BOTTOM;
}
} else {
scaledX *= xMoveScale;
scaledY *= yMoveScale;
switch (orientation) {
case Surface.ROTATION_90:
temp = scaledX;
scaledX = scaledY;
scaledY = -temp;
break;
case Surface.ROTATION_180:
scaledX = -scaledX;
scaledY = -scaledY;
break;
case Surface.ROTATION_270:
temp = scaledX;
scaledX = -scaledY;
scaledY = temp;
break;
}
}
changed = false;
if (down != lastDown) {
int action;
lastDown = down;
if (down) {
action = MotionEvent.ACTION_DOWN;
downTime = curTime;
} else {
action = MotionEvent.ACTION_UP;
}
currentMove = null;
if (!isAbs) {
x = y = 0;
}
return MotionEvent.obtain(downTime, curTime, action,
scaledX, scaledY, scaledPressure, scaledSize, metaState,
更多精彩
赞助商链接