在popwindow中设置显示位置和高度
我在自定义popwindow中设置了写了一个方法
public void showPopupWindow(View parent,int statusBarHeight) {
if (checkPerformShow(parent)) {
mPopupWindow.showAtLocation(parent, Gravity.TOP,0,statusBarHeight);
}
}
//显示位置
//在调用popwindow的显示方法时
Rect rectangle = new Rect();
Window window = getActivity().getWindow();
View parent = getActivity().getWindow().getDecorView();
//获取到手机状态栏的高度
window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
int statusBarHeight = rectangle.top;
//动态设置状态栏的高度
// myScreenPop.setHeight(parent.getMeasuredHeight() - statusBarHeight);
//并将popwindow的显示的初始位置的顶部也就是Y坐标开始显示
myScreenPop.showPopupWindow(parent, statusBarHeight);