参考: 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);
}
}
网友评论