试了网上查看的很多方法。。
就这个生效了。
if (Build.VERSION.SDK_INT < 24) { popupwindow.showAsDropDown(mToolbar); } else { Rect visibleFrame = new Rect(); mToolbar.getGlobalVisibleRect(visibleFrame); int height = mToolbar.getResources().getDisplayMetrics().heightPixels - visibleFrame.bottom; popupwindow.setHeight(height); popupwindow.showAsDropDown(mToolbar, 0, 0); }