我在这里遇到了一个真正的问题,我在过去几个小时里一直在拼命想弄清楚。没到任何地方......
在编写我需要在屏幕上处理两根手指的确切位置的应用程序时,我遇到了一个意外的行为(对我来说)。
经过一些调试,我发现当我将一根手指放在屏幕上的静态位置,同时用另一根手指在同一屏幕上滑动时,不仅会改变移动的坐标,还会改变静态手指的坐标! (虽然不是现实生活中的:D)
以下是仅y坐标的示例日志输出
y(0)是屏幕底部的静态手指和
y(1)从上到下移动。
有趣的是,在我到达屏幕底部之前,y(1)达到最大值480。
有人可以向我解释一下这种行为吗?
这是我用来生成日志的代码,也许我犯了一个愚蠢的错误......
编辑:测试了“htc欲望”。
@Override
public boolean onTouchEvent( MotionEvent e ) {
String s = "";
for ( int i = 0; i < e.getPointerCount(); i++ ) {
s += "y(" + i + ")=" + (int)e.getY( i ) + " ";
}
Log.d( "some tag", s );
return true;
}
- 09-11 17:57:09.257:D / TouchHandler(14932):y(0)= 480
- 09-11 17:57:09.267:D / TouchHandler(14932):y(0)= 480 y(1)= 5
- 09-11 17:57:09.287:D / TouchHandler(14932):y(0)= 480 y(1)= 10
- 09-11 17:57:09.327:D / TouchHandler(14932):y(0)= 480 y(1)= 30
- 09-11 17:57:09.367:D / TouchHandler(14932):y(0)= 480 y(1)= 70
- 09-11 17:57:09.427:D / TouchHandler(14932):y(0)= 480 y(1)= 121
- 09-11 17:57:09.528:D / TouchHandler(14932):y(0)= 480 y(1)= 206
- 09-11 17:57:09.608:D / TouchHandler(14932):y(0)= 480 y(1)= 271
- 09-11 17:57:09.618:D / TouchHandler(14932):y(0)= 480 y(1)= 281
- 09-11 17:57:09.628:D / TouchHandler(14932):y(0)= 447 y(1)= 293
- 09-11 17:57:09.638:D / TouchHandler(14932):y(0)= 447 y(1)= 304
- 09-11 17:57:09.658:D / TouchHandler(14932):y(0)= 428 y(1)= 311
- 09-11 17:57:09.668:D / TouchHandler(14932):y(0)= 419 y(1)= 317
- 09-11 17:57:09.678:D / TouchHandler(14932):y(0)= 415 y(1)= 325
- 09-11 17:57:09.688:D / TouchHandler(14932):y(0)= 413 y(1)= 333
- 09-11 17:57:09.698:D / TouchHandler(14932):y(0)= 411 y(1)= 351
- 09-11 17:57:09.708:D / TouchHandler(14932):y(0)= 411 y(1)= 363
- 09-11 17:57:09.718:D / TouchHandler(14932):y(0)= 411 y(1)= 373
- 09-11 17:57:09.728:D / TouchHandler(14932):y(0)= 411 y(1)= 383
- 09-11 17:57:09.748:D / TouchHandler(14932):y(0)= 480 y(1)= 480
- 09-11 17:57:09.758:D / TouchHandler(14932):y(0)= 459 y(1)= 438
- 09-11 17:57:09.768:D / TouchHandler(14932):y(0)= 459 y(1)= 432
- 09-11 17:57:09.778:D / TouchHandler(14932):y(0)= 445 y(1)= 431
- 09-11 17:57:09.788:D / TouchHandler(14932):y(0)= 439 y(1)= 432
- 09-11 17:57:09.798:D / TouchHandler(14932):y(0)= 437 y(1)= 436
- 09-11 17:57:09.818:D / TouchHandler(14932):y(0)= 439 y(1)= 441
- 09-11 17:57:09.828:D / TouchHandler(14932):y(0)= 443 y(1)= 447
- 09-11 17:57:09.838:D / TouchHandler(14932):y(0)= 450 y(1)= 456
- 09-11 17:57:09.838:D / TouchHandler(14932):y(0)= 459 y(1)= 467
- 09-11 17:57:09.858:D / TouchHandler(14932):y(0)= 469 y(1)= 480
- 09-11 17:57:09.868:D / TouchHandler(14932):y(0)= 476 y(1)= 480
- 09-11 17:57:09.878:D / TouchHandler(14932):y(0)= 479 y(1)= 480
- 09-11 17:57:09.888:D / TouchHandler(14932):y(0)= 480 y(1)= 480