popupwindow是悬浮显示在当前activity之上的一个窗体
//第一步 声明对象:-2表示包裹内容,-1表示填充父窗体,contentView可以自由发挥
PopupWindow popupWindow=new PopupWindow(contentView, -2, -2);
//第二步 设置背景之类的东西
popupWindow.setBackgroundDrawable(new ColorDrawable(Color.BLUE));
//第三步 设置显示的位置
int location[] = new int[2];
view.getLocationInWindow(location);// 获得当前条目的位置
popupWindow.showAtLocation(parent, Gravity.TOP | Gravity.LEFT, location[0], location[1]);
//第四步 取消显示旧窗体
if (popupWindow != null && popupWindow.isShowing()) {
// 判断是否有popupwindow在显示,关闭旧的窗体
popupWindow.dismiss();
popupWindow = null;
}