Android AlertDialog背景透明

1.定义AlertDialog透明样式

<style name="TransparentDialog" parent="Theme.AppCompat.Dialog">
    "android:windowBackground">@color/transparent
style>

colors.xml

<color name="transparent">#00000000color>

2.创建AlertDialog

View contentView= LayoutInflater.from(context).inflate(R.layout.dialog_progress, null);
AlertDialog.Builder builder=new AlertDialog.Builder(context,R.style.TransparentDialog);
builder.setView(contentView);
builder.setCancelable(false);
builder.show();

你可能感兴趣的:(android)