我不能慢慢画一条直线!当我慢慢滑动时,我有一条波浪线而不是一条直线。
我尝试使用“指针位置”工具来检查点,我得到了相同的结果。但是当我快速、垂直或水平滑动时,我得到了直线......
这是我的代码
public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
String ms;
switch (event.getAction()){
case MotionEvent.ACTION_DOWN:
int xDown = (int)event.getX();
int yDown = (int)event.getY();
ms = "down";
out.println(xDown);
out.println(yDown);
out.println(ms);
break;
case MotionEvent.ACTION_MOVE:
ms = "move";
int hsize = event.getHistorySize();
for(int i=0;i<hsize;i++)
{
int x = (int)event.getHistoricalX(i);
int y = (int)event.getHistoricalY(i);
int hx = x;
int hy = y;
out.println(hx);
out.println(hy);
out.println(ms);
}
/*
int xMove = (int)event.getX();
int yMove = (int)event.getY();
out.println(xMove);
out.println(yMove);
ms = "move";
out.println(ms);
*/
break;
case MotionEvent.ACTION_UP:
int xUp = (int)event.getX();
int yUp = (int)event.getY();
out.println(xUp);
out.println(yUp);
ms = "up";
out.println(ms);
break;
}
return false;
}