PopupWindow z ordering PopupWindow z ordering android android

PopupWindow z ordering


Found anwer myself.

Those decorations are normal PopupWindow-s, managed by EditText.

Z-ordering of any Window is defined by WindowManager.LayoutParams.type, actually it defines purpose of Window. Valid ranges are FIRST_SUB_WINDOW - LAST_SUB_WINDOW for a popup window.

App typically can't change "type" of PopupWindow, except of calling hidden function PopupWindow.setWindowLayoutType(int) using Java reflection, and setting desired window type.

Result:

enter image description here

EDIT:Code that does that:

  Method[] methods = PopupWindow.class.getMethods();  for(Method m: methods){     if(m.getName().equals("setWindowLayoutType")) {        try{           m.invoke(getPopupWindow(), WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL);        }catch(Exception e){           e.printStackTrace();        }        break;     }  }


import android.support.v4.widget.PopupWindowCompat;PopupWindowCompat.setWindowLayoutType(popupWindow, WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL);


public void compatibleSetWindowLayoutType(int layoutType) {    if (Build.VERSION.SDK_INT >= 23) {        setWindowLayoutType(layoutType);    } else {        try {            Class c = this.getClass();            Method m = c.getMethod("setWindowLayoutType", Integer.TYPE);            if(m != null) {                m.invoke(this, layoutType);            }        } catch (Exception e) {        }    }}