dialog去除阴影和半透明背景

private AlertDialog dialogprogress = null;

    @Override
    public void showProgress(String msg) {
        if (null != dialogprogress && dialogprogress.isShowing()) {
            dialogprogress.dismiss();
        }
        // 设置窗口的内容页面
        if ((null == dialogprogress || !dialogprogress.isShowing())) {

            dialogprogress = new AlertDialog.Builder(mContext).create();
            dialogprogress.show();
            dialogprogress.setCancelable(setCanTouchDimiss());

            Window window = dialogprogress.getWindow();
            window.setBackgroundDrawableResource(R.color.transparent);

            //去除半透明阴影
            WindowManager.LayoutParams layoutParams = window.getAttributes();
            layoutParams.dimAmount = 0.0f;
            window.setAttributes(layoutParams);
            // *** 主要就是在这里实现这种效果的.
            // 设置窗口的内容页面,shrew_exit_dialog.xml文件中定义view内容
//            window.setContentView(R.layout.progress);
        }
    }


    @Override
    public void hideProgress() {
        if (null != dialogprogress && dialogprogress.isShowing()) {
            // 关闭对话框
            dialogprogress.dismiss();
        }
        dialogprogress = null;

    }

 

你可能感兴趣的:(UI)