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