美文网首页
Android7.0 ,7.1,8.0 popupwindow

Android7.0 ,7.1,8.0 popupwindow

作者: lhybxs | 来源:发表于2018-03-06 17:48 被阅读0次

参考: 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

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