方法:
在你extends的PopupWindow中添加如下代码:
@Override
public void showAsDropDown(View anchor) {//为了适配android 7.0以上的showAsDropDown失效的问题
if (Build.VERSION.SDK_INT >= 24) {
Rect rect = new Rect();
anchor.getGlobalVisibleRect(rect);
int h = anchor.getResources().getDisplayMetrics().heightPixels - rect.bottom;
setHeight(h);
}
super.showAsDropDown(anchor);
}