PopupWindow在某个View之上

View popuView = LayoutInflater.from(this).inflate(R.layout.purrify_main_poupow, null);
		popuView.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
		popupWidth = popuView.getMeasuredWidth();
		popupHeight = popuView.getMeasuredHeight();
		popupWindow = new PopupWindow(popuView, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, true);


int[] location = new int[2];
			ibtReturnChargeOrNot.getLocationOnScreen(location);

			popupWindow.showAtLocation(ibtReturnChargeOrNot, Gravity.NO_GRAVITY, (location[0] + view.getWidth() / 2) - popupWidth / 2, location[1] - popupHeight);

  

原文地址:https://www.cnblogs.com/qcgAd/p/5533937.html