1.定义AlertDialog透明样式
<style name="TransparentDialog" parent="Theme.AppCompat.Dialog"> <item name="android:windowBackground">@android:color/transparent</item> </style>
2.创建AlertDialog
View view = LayoutInflater.from(context).inflate(R.layout.dialog_sure, null, false); AlertDialog sureDialog = new AlertDialog.Builder(context, R.style.TransparentDialog).setView(view).create();
参考链接: