popupwindow设置位置

mRadioGroup.getLocationOnScreen(location);
int w = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED);
int h = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED);
mRadioGroup.measure(w, h);
kyqNewsPopupWindow.setTvNotice("测试测试事儿成都");
kyqNewsPopupWindow.getContentView().measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
int popWidth=kyqNewsPopupWindow.getContentView().getMeasuredWidth();
int popHeight=kyqNewsPopupWindow.getContentView().getMeasuredHeight();
int height = mRadioGroup.getMeasuredHeight();
int x = getScreenWidth(getBaseContext())*5/8-popWidth/2;
int y = location[1]-height-14;
kyqNewsPopupWindow.showAtLocation(mRadioGroup, Gravity.NO_GRAVITY, x, y);

猜你喜欢

转载自blog.csdn.net/qq7915/article/details/88890427