參考:?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);
? ? }
}