private void showPopupWindow(View view) {
View contentView = LayoutInflater.from(getContext()).inflate(
R.layout.popupwindow_introduction, null);
//收益方式描述
TextView tvIncomeDesc = (TextView) contentView.findViewById(R.id.tv_pop_content);
String incomeDesc = fixedPeriodInvestProdResp.getIncomeDesc();
if (!TextUtils.isEmpty(incomeDesc)) {
tvIncomeDesc.setText(incomeDesc);
}
final PopupWindow popupWindow = new PopupWindow(contentView,
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, true);
//代码计算高度
popupWindow.getContentView().measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
popupWindow.setTouchable(true);
// 如果不设置PopupWindow的背景,无论是点击外部区域还是Back键都无法dismiss弹框
popupWindow.setBackgroundDrawable(getResources().getDrawable(
R.drawable.pop_bg_introduction_civmode));
int xoff = (view.getWidth() - popupWindow.getContentView().getMeasuredWidth()) / 2;
popupWindow.showAsDropDown(view, xoff, 0);
}
popwindow点击之后计算高度
最新推荐文章于 2022-11-17 11:15:06 发布
本文介绍了一个使用PopupWindow显示自定义视图的方法。该方法通过LayoutInflater加载布局资源,并根据需要显示的内容进行填充。同时,详细说明了如何测量PopupWindow的大小、设置触摸反馈及背景等属性。
1244

被折叠的 条评论
为什么被折叠?



