我正在开发绘图应用程序我正在使用event.getRawX()
来获取屏幕触摸信息。我希望在android画布绘制区域中正确映射event.getRawX()
和event.getX()
。实现这个目标?
答案 0 :(得分:1)
尝试做这样的事情
public boolean onTouch(final View v, final MotionEvent event) {
int rawXCord, rawYCord;
final int actionIndex = event.getAction() >> MotionEvent.ACTION_POINTER_ID_SHIFT;
final int location[] = { 0, 0 };
v.getLocationOnScreen(location);
rawXCord= (int) event.getX(actionIndex) + location[0];
rawYCord= (int) event.getY(actionIndex) + location[1];
//do ahead accordingly
}