答案 0 :(得分:0)
您只需要为此实现触摸事件列表器。
view.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int X = (int) event.getX();
int Y = (int) event.getY();
int eventaction = event.getAction();
switch (eventaction) {
case MotionEvent.ACTION_DOWN:
Toast.makeText(this, "Finger down coordinate " + "X: " + X + " Y: " + Y, Toast.LENGTH_SHORT).show();
isTouch = true;
break;
case MotionEvent.ACTION_MOVE:
Toast.makeText(this, "Finger move coordinate " + "X: " + X + " Y: " + Y, Toast.LENGTH_SHORT).show();
break;
case MotionEvent.ACTION_UP:
Toast.makeText(this, "Finger up coordinate " + "X: " + X + " Y: " + Y, Toast.LENGTH_SHORT).show();
break;
}
return true;
}
});