在popupWindow show的時候,采用以下代碼
if(android.os.Build.VERSION.SDK_INT>=24) {
int[] a =new int[2];
findViewById(R.id.app_bar_layout).getLocationInWindow(a);
popupWindow.showAtLocation(getWindow().getDecorView(),Gravity.NO_GRAVITY,0,a[1]+findViewById(R.id.app_bar_layout).getHeight());
}else{
popupWindow.showAsDropDown(findViewById(R.id.app_bar_layout));
}