如何在Dialog中删除黑色矩形框?

时间:2022-08-26 22:00:59

I used the following code to prepare an custom dialog,it is showing my custom layout in a black colored rectangle box.

我使用以下代码准备一个自定义对话框,它在黑色矩形框中显示我的自定义布局。

final Dialog dialog = new Dialog(getParent(),R.style.PauseDialog);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
dialog.setContentView(R.layout.social_share);
dialog.setTitle("Social Sharing");
dialog.setCancelable(true);

How to remove that box,which should show only my custom layout.

如何删除该框,该框应仅显示我的自定义布局。

Thanks!

1 个解决方案

#1


0  

You can set background with <shape> as per your requirement in your customize dialog

您可以在自定义对话框中根据您的要求使用 设置背景

In custom_dialog_layout.xml:

android:background = "@layout/dialog_shape"

then in dialog_shape.xml:

然后在dialog_shape.xml中:

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
     android:shape="rectangle" > 
     <gradient android:startColor="#FF0E2E57" 
     android:endColor="#FF0E2E57" 
            android:angle="225" android:paddingLeft="20dip"/> 
</shape>

#1


0  

You can set background with <shape> as per your requirement in your customize dialog

您可以在自定义对话框中根据您的要求使用 设置背景

In custom_dialog_layout.xml:

android:background = "@layout/dialog_shape"

then in dialog_shape.xml:

然后在dialog_shape.xml中:

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
     android:shape="rectangle" > 
     <gradient android:startColor="#FF0E2E57" 
     android:endColor="#FF0E2E57" 
            android:angle="225" android:paddingLeft="20dip"/> 
</shape>