title: How could I drag a popup view outside of screen in Android?
body: <p>I got a popup window that is generated with the help of <code>WindowManager</code> and with these params (as you can find in other stackoverflow questions):</p>
  
  <pre><code>new WindowManager.LayoutParams(
    ViewGroup.LayoutParams.WRAP_CONTENT,
    ViewGroup.LayoutParams.WRAP_CONTENT,
    WindowManager.LayoutParams.TYPE_PHONE,
    WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
    PixelFormat.TRANSLUCENT
  )
  </code></pre>
  
  <p>My question is similar to this one: <a href="https://stackoverflow.com/questions/13009318/android-drag-view-outside-screen">Android: Drag View outside screen</a> and also similar to this one: <a href="https://stackoverflow.com/questions/19581157/dragging-a-view-outside-of-relativelayout">Dragging a view outside of RelativeLayout</a></p>
  
  <p>The difference is that the <code>WindowManager.LayoutParams</code> do not include any kind of margins, therefore it is not possible to use the margin tricks with relative layout etc.</p>
  
  <p>Any idea on how I could drag the view outside of the android screen boundaries?</p>
  
  <p>Thank you</p>
  
  <p><em>Edit</em>:<br>
  As you asked here is the related code that does the dragging for the time being</p>
  
  <pre><code>view.setOnTouchListener(new OnTouchListener {
    def onTouch(view: View, motionEvent: MotionEvent): Boolean = {
      val x = motionEvent.getRawX.toInt
      val y = motionEvent.getRawY.toInt
  
      motionEvent.getAction &amp; MotionEvent.ACTION_MASK match {
        case MotionEvent.ACTION_DOWN =&gt;
          val params = view.getLayoutParams.asInstanceOf[WindowManager.LayoutParams]
  
          xDelta = x - params.x
  
          yDelta = y - params.y
  
        case MotionEvent.ACTION_UP =&gt;
          draggingOn = false
  
        case MotionEvent.ACTION_MOVE =&gt;
          if (draggingOn) {
            val params = view.getLayoutParams.asInstanceOf[WindowManager.LayoutParams]
  
            params.x = x - xDelta
  
            params.y = y - yDelta
  
            //view.setLayoutParams(params)
            windowManager.updateViewLayout(view, params)
  
            //log log "current x is: " + x
  
            //log log "current y is: " + y
          } else {
            //nop
          }
  
        case _ =&gt;
        //case MotionEvent.ACTION_POINTER_DOWN =&gt;
        //case MotionEvent.ACTION_POINTER_UP =&gt;
      }
  
      false
    }
  })
  </code></pre>
  
  <p><em>above code is in scala but I guess you will not have any hard time reading it</em></p>