Android7.0 ,7.1,8.0 popupwindow showAsDropDown 显示异常解决办法

参考: http://blog.csdn.net/ithe1001/article/details/56281750

Android7.0 以上popupwindow showAsDropDown在屏幕上方弹出解决方法,通过版本控制解决,


public static void showAsDropDown(PopupWindow pw, View anchor, int xoff, int yoff) {

    if (Build.VERSION.SDK_INT >= 24) {

        Rect visibleFrame = new Rect();

        anchor.getGlobalVisibleRect(visibleFrame);

        int height = anchor.getResources().getDisplayMetrics().heightPixels - visibleFrame.bottom;

        pw.setHeight(height);

        pw.showAsDropDown(anchor, xoff, yoff);

    } else {

        pw.showAsDropDown(anchor, xoff, yoff);

    }

}

你可能感兴趣的:(Android7.0 ,7.1,8.0 popupwindow showAsDropDown 显示异常解决办法)