Android AlertDialog背景透明

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();

参考链接:

Android AlertDialog背景透明

发表评论