具有透明背景的Android对话框

具有透明背景的Android对话框

如何从Android对话框中删除黑色背景。图中显示了问题所在。

final Dialog dialog = new Dialog(Screen1.this);

dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

dialog.setContentView(R.layout.themechanger); 


www说
浏览 652回答 3
3回答

沧海一幻觉

添加以下代码 dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));编辑dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);

缥缈止盈

<style&nbsp;name="NewDialog"> &nbsp;&nbsp;&nbsp;&nbsp;<item&nbsp;name="android:windowFrame">@null</item> &nbsp;&nbsp;&nbsp;&nbsp;<item&nbsp;name="android:windowBackground">@android:color/transparent</item> &nbsp;&nbsp;&nbsp;&nbsp;<item&nbsp;name="android:windowIsFloating">true</item> &nbsp;&nbsp;&nbsp;&nbsp;<item&nbsp;name="android:windowContentOverlay">@null</item> &nbsp;&nbsp;&nbsp;&nbsp;<item&nbsp;name="android:windowTitleStyle">@null</item> &nbsp;&nbsp;&nbsp;&nbsp;<item&nbsp;name="android:windowAnimationStyle">@android:style/Animation.Dialog</item> &nbsp;&nbsp;&nbsp;&nbsp;<item&nbsp;name="android:windowSoftInputMode">stateUnspecified|adjustPan</item> &nbsp;&nbsp;&nbsp;&nbsp;<item&nbsp;name="android:backgroundDimEnabled">false</item> &nbsp;&nbsp;&nbsp;&nbsp;<item&nbsp;name="android:background">@android:color/transparent</item></style>在java中使用Dialog&nbsp;dialog&nbsp;=&nbsp;new&nbsp;Dialog(this,&nbsp;R.style.NewDialog);希望能帮你!
打开App,查看更多内容
随时随地看视频慕课网APP