全面屏时popupWindow弹窗底部空白的解决方案

android7.0时,popupWindow弹窗位置异常,当时的解决方案是:https://blog.csdn.net/zhihui_520/article/details/79097161

但是这种方法, 如果是全面屏的话,会出现底部部分空白的问题,解决方法:

    public void showAsDropDown(View anchor, int xoff, int yoff) {
        if (Build.VERSION.SDK_INT >= 24) {

            Rect rect = new Rect();
            anchor.getWindowVisibleDisplayFrame(rect);
            Activity activity = (Activity) anchor.getContext();
            Rect outRect1 = new Rect();
            activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(outRect1);
            int h = outRect1.height() - rect.bottom;
            setHeight(h);
        }
        super.showAsDropDown(anchor, xoff, yoff);
    }

 

你可能感兴趣的:(全面屏时popupWindow弹窗底部空白的解决方案)