title: Android: How to drag(move) PopupWindow?
body: <p>I want to be able to move PopupWindow on touch dragging.
  I don't want UI to update on the release of the touch. I want PopupWindow to follow my touch.</p>
  
  <p>This is something what I am doing:</p>
  
  <pre><code>mView = mLayoutInflater.inflate(R.layout.popup,
                  null);
  mPopupWindow = new PopupWindow(mView,
                 LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, false);
  mPopupWindow.showAtLocation(parentView, Gravity.CENTER, -5, 30);
  
  mView.setOnTouchListener(new OnTouchListener() {
          private int dx = 0;
          private int dy = 0;
  
          @Override
          public boolean onTouch(View view, MotionEvent motionEvent) {
              switch (motionEvent.getAction()) {
                  case MotionEvent.ACTION_DOWN:
                      dx = (int) motionEvent.getX();
                      dy = (int) motionEvent.getY();
                      break;
                  case MotionEvent.ACTION_MOVE:
                      int x = (int) motionEvent.getX();
                      int y = (int) motionEvent.getY();
                      int left =  (x - dx);
                      int top =   (y - dy);
                      Log.d("test", "x: " + left + " y: " + top);
                      mPopupWindow.update(left, top, -1, -1);
                      break;
              }
              return true;
          }
      });
  </code></pre>
  
  <p>What happens is, as I drag the popup window, it flickers back and forth on the original location and where my finger is.</p>
  
  <p>Flickering Logcat Result:</p>
  
  <pre><code>x: -44 y: 4
  x: -43 y: 37
  x: -46 y: 4
  x: -46 y: 38
  x: -48 y: 4
  x: -47 y: 38
  x: -50 y: 4
  </code></pre>
  
  <p>But if I remove (comment out) "mPopupWindow.update(left, top, -1, -1);", it returns correct result.
  (But obviously UI won't update):</p>
  
  <pre><code>x: -33 y: 0
  x: -37 y: 0
  x: -41 y: 0
  x: -43 y: 3
  x: -46 y: 3
  x: -50 y: 3
  x: -54 y: 4
  x: -57 y: 4
  </code></pre>
  
  <p>How would I move a PopupWindow correctly?</p>