popwindow点击之后计算高度

来源:互联网 发布:ftp同步软件 linx 编辑:程序博客网 时间:2024/06/14 02:33
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);    }
原创粉丝点击