答案 0 :(得分:1)
尝试一下
final Dialog dialog = new Dialog(mContext, R.style.Theme_Transparent);
View view = LayoutInflater.from(mContext)
.inflate(R.layout.layout_custom_dialog, null);
dialog.setContentView(view);
Window window = dialog.getWindow();
WindowManager.LayoutParams wlp = window.getAttributes();
wlp.width = wlp.MATCH_PARENT;
wlp.gravity = Gravity.TOP;
wlp.flags &= ~WindowManager.LayoutParams.FLAG_BLUR_BEHIND;
window.setAttributes(wlp);
并将其添加到styles.xml
文件
<style name="Theme.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">true</item>
</style>