美文网首页
PopupWindow基本属性设置

PopupWindow基本属性设置

作者: 哈达拉进来了 | 来源:发表于2017-08-09 22:59 被阅读12次
 private void init(final Context context) {
        View view = LayoutInflater.from(context).inflate(R.layout.bottom_dialog_layout, null);
        setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
        int height= ScreenUtils.getScreenHeight()*2/3;
        setHeight(height);
        setContentView(view);
        initView(context, view);
        setBackgroundDrawable(new ColorDrawable(0x00000000));
        setOutsideTouchable(true);
        setFocusable(true);
        setAnimationStyle(R.style.PayPopupStyle);
        setOnDismissListener(new OnDismissListener() {
            @Override
            public void onDismiss() {
                WindowManager.LayoutParams param = ((Activity) context).getWindow().getAttributes();
                param.alpha = 1f;
                ((Activity) context).getWindow().setAttributes(param);
            }
        });
    }

 @Override
    public void showAtLocation(View parent, int gravity, int x, int y) {
        super.showAtLocation(parent, gravity, x, y);
        WindowManager.LayoutParams param = ((Activity) context).getWindow().getAttributes();
        param.alpha = 0.7f;
        ((Activity) context).getWindow().setAttributes(param);
    }

相关文章

网友评论

      本文标题:PopupWindow基本属性设置

      本文链接:https://www.haomeiwen.com/subject/cckcrxtx.html