private void showWinddowAbove(View view,int dra){
View contentView = LayoutInflater.from(getActivity()).inflate(
R.layout.poplay, null);
if(popupWindow == null){
popupWindow = new PopupWindow(contentView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
popupWindow.setFocusable(true);
popupWindow.setOutsideTouchable(true);
// 如果不设置PopupWindow的背景,有些版本就会出现一个问题:无论是点击外部区域还是Back键都无法dismiss弹框
popupWindow.setBackgroundDrawable(getResources().getDrawable(
R.drawable.circle_bg));
face_img = contentView.findViewById(R.id.face_img);
}
Glide.with(getActivity()).load(dra).into(face_img);
int[] location = new int[2];
view.getLocationOnScreen(location);
popupWindow.showAtLocation(view, Gravity.NO_GRAVITY, location[0], location[1] - popupWindow.getHeight());
//在控件的下方弹出窗口
//popupWindow.showAsDropDown(view);
//左边
//popupWindow.showAtLocation(view, Gravity.NO_GRAVITY, location[0] - view.getWidth(), location[1]);
//右边
//popupWindow.showAtLocation(view, Gravity.NO_GRAVITY, location[0] + view.getWidth(), location[1]);
}
我的需求是上面撒,这边可以调整距离以及位置的