PopupWindow popupWindow = new PopupWindow();
popupWindow.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
popupWindow.setHeight(80);
1.设置宽高 根据自己的需求设置 宽高是弹框不可缺少的
popupWindow.setOutsideTouchable(true);
popupWindow.setFocusable(true);
2.setOutsideTouchable 点击弹框外 关闭弹
3.setFocusable(true) 设置 popupWindow 是否可以获取焦点
View inflate = LayoutInflater.from(Activity_details.this).inflate(R.layout.deta, null);
popupWindow.setContentView(inflate);
4.加载布局 LayoutInflater.from(this).inflate(R.id.deta,null)
5.setContentView(inflate) PopupWindow添加布局
popupWindow.showAsDropDown(imgPl, Gravity.BOTTOM, 0, 0);
6.设置布局显示的位置 第一个参数是要显示在那个控件的位置 第二个参数的 设置布局的位置显示在那里 后面那个参数 设置布局上下左右移动的