去掉自定义dialog的白色背景

遇到了两次,记录一下

Dialog dialog = new Dialog(this);
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
View contentView = LayoutInflater.from(this).inflate(R.layout.dialog_discount, null);
contentView.findViewById(R.id.close).setOnClickListener(v1 -> dialog.dismiss());
dialog.setContentView(contentView);
dialog.setCancelable(false);
dialog.show();

dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
添加这一句

猜你喜欢

转载自blog.csdn.net/alwaysgoalong/article/details/78206885