I created an onTouchListener to drag and drop Views. If you use getRawX() and getRawY() , images smoothly drag and drop. The problem is that the image will jump to the second pointer when you place the second pointer down, then raise the first pointer.
This onTouchListener is trying to fix this problem by tracking pointerId . The problem with this onTouchListener is dragging and dropping the ImageView, the ImageView is jumping around pretty crazy. The values getX() and getY() moved.
I feel like doing it right. I do not want to write a custom view for this, because I already implemented a scaleGestureDetector and wrote my own rotateGestureDetector, which works. Everything works fine, but I need to fix the problem that I get when using getRawX() and getRawY() .
Does anyone know what I'm doing wrong here?
Here is my onTouchListener:
final View.OnTouchListener onTouchListener = new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { relativeLayoutParams = (RelativeLayout.LayoutParams) v.getLayoutParams(); final int action = event.getAction(); switch (action & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: { final float x = event.getX(); final float y = event.getY();
source share