使用自定义主题删除警报对话框边框

Sat*_*esh 3 android android-alertdialog

在此输入图像描述

在我的应用程序中,我使用圆角矩形主题的警告对话框.但它有alertdialog矩形和我的主题.我的问题是如何替换像对话框的警告对话框边框.我想只显示这个设置项目与自己的主题.

我希望以这种方式输出而不是上面的主题:

在此输入图像描述

主要活动:

AlertDialog.Builder alertSeverity = new AlertDialog.Builder(
           getActivity(), R.style.Theme_CustomDialog);
     alertSeverity.setTitle("Severity Status");
CharSequence[] severityStatus = { "Low-Severity",
           "Middle-Severity", "High-Severity" };
     alertSeverity.setItems(severityStatus,
           new DialogInterface.OnClickListener() {        

              @Override
              public void onClick(DialogInterface dialog, int which) {
                }
                 });
Run Code Online (Sandbox Code Playgroud)

我的主题:

<style name="Theme.CustomDialog" parent="android:style/Theme.Dialog">
    <item name="android:windowBackground">@drawable/shapedialogtheme</item>
<item name="android:windowFrame">@null</item>

</style>

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"  >

<solid android:color="#565656" />

<stroke
    android:width="5dp"
    android:color="#ffff8080" />

<corners android:radius="30dp" />

<padding
    android:bottom="10dp"
    android:left="10dp"
    android:right="10dp"
    android:top="10dp" />
<size 
    android:width="150dp"
    android:height="150dp"/>

</shape>
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

Nir*_*tel 6

使用Dialog而不是AlertDialog.

创建要在对话框中显示的自定义布局和对话框中的setContent.android.R.style.Theme_Translucent_NoTitleBar在对话框中应用此主题将隐藏边框.

这是示例代码.

Dialog dialog = new Dialog(activity.this, android.R.style.Theme_Translucent_NoTitleBar);

// your layout file
dialog.setContentView(R.layout.dialog);

// for hide title 
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

//for set title
dialog.setTitle("Custom Dialog");


dialog.show();
Run Code Online (Sandbox Code Playgroud)

更新:

刚在AlertDialog中试过这个.

AlertDialog.Builder alertSeverity = new AlertDialog.Builder(
           getActivity(), android.R.style.Theme_Translucent_NoTitleBar);
Run Code Online (Sandbox Code Playgroud)