public void show(){
//显示位置 一开始写的
//popupWindow.showAsDropDown(relayView);
//后来改的
showAsDropDown(popupWindow,relayView,0,relayView.getHeight());
popupWindow.update();
}
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, 0, 0);
}
}
出处忘记了,但是亲测可用,做个记录。侵权即删