美文网首页
Android 7.0以上PopupWindow 位置异常

Android 7.0以上PopupWindow 位置异常

作者: WSM_666 | 来源:发表于2018-06-07 14:19 被阅读5次

public static void showAsDropDown(final PopupWindow pw, final View anchor, final int xoff, final 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);

    }

}

相关文章

网友评论

      本文标题:Android 7.0以上PopupWindow 位置异常

      本文链接:https://www.haomeiwen.com/subject/itdgsftx.html