I am making an app that needs pinch zoom and drag pan for a relative view. When I first implemented drag pan it jumped all over the place. Using getRawX
and getRawY
fixed my problems. I am now working on pinch zoom and my app is once again jumping all over the place. I tried using getRawX
, but apparently I can only do that for one of the points. It does not allow something like event.getRawX(0);
and event.getRawX()
will only return the values for one of the points. How can I get RawX for both touchpoints?
Asked
Active
Viewed 1,110 times
3

ROMANIA_engineer
- 54,432
- 29
- 203
- 199

clavio
- 1,022
- 1
- 16
- 34
3 Answers
0
The trick is to record both fingers separately as the screen is touched. Then track the drag gesture as the fingers are moved.

Community
- 1
- 1

HarshMarshmallow
- 1,007
- 11
- 23
-1
You can use getX (int pointerIndex)
and getY (int pointerIndex)
. Those 2 functions are defined here Developer android, for more detail how to get pointerIndex
: Pointer Index

Kingfisher Phuoc
- 8,052
- 9
- 46
- 86
-
getX and getY do not work. They cause the "jumping" I'm experiencing. – clavio Oct 30 '12 at 12:22
-1
I figured it out. Nice job me
float x = (event.getXPrecision()*event.getX(0)) - (event.getXPrecision()*event.getX(1));
float y = (event.getYPrecision()*event.getY(0)) - (event.getYPrecision()*event.getY(1));
So basically event.getXPrecision()*event.getX(0) is the getRawX of pointer(0)

clavio
- 1,022
- 1
- 16
- 34
-
3This doesn't get you the raw x/y values. Multiplying by the precision values just gives you the actual hardware coordinates. You'll still get relative values per the documentation. The reason this solves your problem is probably because what you really wanted was the distance between the two fingers, in which it won't matter if you use relative or absolute coordinates. – Dia Kharrat Mar 21 '13 at 07:38