1、style添加样式
<style name="loading_dialog_style" parent="@android:style/Theme.DeviceDefault.Light.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style>
backgroundDimEnabled 属性背景是否变暗
android:backgroundDimEnabled
2、使用
AlertDialog.Builder builder = new AlertDialog.Builder(this,R.style.loading_dialog_style);
final AlertDialog alertDialog = builder.create();
alertDialog.setCanceledOnTouchOutside(false);
alertDialog.show();
// inflate就没有了最外层的布局了。
View view = View.inflate(this, R.layout.dialog_exit_app, null);
// setContentView 必须在show后
alertDialog.getWindow().setContentView(view);