如何在Android屏幕上同时触摸两个点的坐标?

时间:2012-09-07 11:12:02

标签: android ontouchevent ontouchlistener

我想知道,当同时触摸屏幕上的点时,可以获得两组正确的坐标点。 如果是,那么如何使用它。谷歌搜索但没有得到任何满意的结果。请帮忙吗?

1 个答案:

答案 0 :(得分:0)

使用以下两种方法代替getX和getY:

public final float getX (int pointerIndex)
        Since: API Level 5

        Returns the X coordinate of this event for the given pointer index (use getPointerId(int) to find the pointer identifier for this index). Whole numbers are pixels; the value may have a fraction for input devices that are sub-pixel precise.


public final float getY (int pointerIndex)
        Since: API Level 5

        Returns the Y coordinate of this event for the given pointer index (use getPointerId(int) to find the pointer identifier for this index). Whole numbers are pixels; the value may have a fraction for input devices that are sub-pixel precise.
        Parameters
        pointerIndex    Raw index of pointer to retrieve. Value may be from 0 (the first pointer that is down) to getPointerCount()-1.