我是通过showAtLocation(View parent, int Gravity, int x, int y)这个方法来确定位置的
1.得到指定的view在屏幕上的位置
int[] location = new int[2];
//flagView是parent
flagView.getLocationOnScreen(location);
2.指定位置(location[0] 和 location[1] 代表了parent左上角点的x、y)
//这个是正下方中间的显示
mPopupWindow.showAtLocation(flagView, Gravity.NO_GRAVITY,
location[0] + (rect.width() - windowView.getMeasuredWidth()) / 2, location[1] + rect.height());