mLocalFrameLayout.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: mLocalX = mLocalFrameLayout.getX() - event.getRawX(); mLocalY = mLocalFrameLayout.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: mLocalFrameLayout.animate() .x(event.getRawX() + mLocalX) .y(event.getRawY() + mLocalY) .setDuration(0) .start(); break; default: return false; } return true; } });