if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
try {
Field mLayoutInScreen = PopupWindow.class.getDeclaredField("mLayoutInScreen");
Method set = PopupWindow.class.getDeclaredMethod("setLayoutInsetDecor", boolean.class);
set.setAccessible(true);
set.invoke(RecyclerViewPopupWindow.this, true);
mLayoutInScreen.setAccessible(true);
mLayoutInScreen.set(RecyclerViewPopupWindow.this, true);
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (NoSuchMethodException | InvocationTargetException e) {
throw new RuntimeException(e);
}
}
最近在弄PopupWindow,需要反射一些变量
debug如图:
效果如图所示:
成功让PopupWindow覆盖状态栏,但是还是仍未覆盖导航栏,目前没有比较好的方案可以覆盖,听说XAlertDialog可以,但是不想更换组件