自己写了一个通用的Dialog,但是在drawable中设置的圆角一直不起作用。后来找到一篇博客,解决了问题 https://blog.csdn.net/denglusha737/article/details/63255577
解决方法;只要设置背景透明解决问题了。
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); //圆角起作用
代码如下所示:
public class CommonDialog extends Dialog{
private TextView tvTitle;
private TextView tvContent;
private TextView tvSure;
private TextView tvCancel;
public CommonDialog(@NonNull Context context, String title, String content, String sure, String cancel) {
super(context);
setContentView(R.layout.dialog_common);
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); //圆角起作用
initView();
conver(title, content, sure, cancel);
}
public void initView(){
tvTitle = findViewById(R.id.dialog_title);
tvContent = findViewById(R.id.dialog_content);
tvSure = findViewById(R.id.dialog_sure);
tvCancel = findViewById(R