Is toggling window types impossible?

46 Views Asked by At

I want users to be able to move an overlay to their chosen position, and also to be able to touch the screen through the overlay. As both are not possible at the same time, I have two buttons, one for moving (TYPE_SYSTEM_ALERT) and one for touching through (TYPE_SYSTEM_OVERLAY).

To toggle from ALERT to OVERLAY, I have this method:

    public static void newLayoutParams (){
    WindowManager.LayoutParams newLayoutParams = new WindowManager.LayoutParams(
            LayoutParams.TYPE_SYSTEM_OVERLAY,
            LayoutParams.FLAG_NOT_FOCUSABLE |
                    LayoutParams.FLAG_LAYOUT_IN_SCREEN,
            PixelFormat.TRANSLUCENT);
    wm.updateViewLayout(overlayButton, newLayoutParams);
}

And in my MainActivity I have this for the button:

    public void validate(View view) {
    OverlayService.newLayoutParams();
}

The problem is that I am getting this error:

Window type can not be changed after the window is added.

So my question is this: Is what I am trying to do impossible or is there a work around?

0

There are 0 best solutions below