android中AlertDialog设置圆角

参考网址:https://blog.csdn.net/qq_33224517/article/details/53421307

说明:在AlertDialog自定义布局的时候,想要一个圆角效果,但是给xml设置圆角后,AlertDialog并不是显示的圆角,只有自定义的布局是圆角样式,AlertDialog会显示出一个白色四方的背景

AlertDialog alertDialog = new AlertDialog.Builder(this).create();
Window window = alertDialog.getWindow(); 
//这一句消除白块 
window.setBackgroundDrawable(new BitmapDrawable());
//自定义的xml
window.setContentView(R.layout.mydialog);
alertDialog.show();


    
    
    

 

你可能感兴趣的:(Android,Studio)