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

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

本文介绍了删除警报对话框边框使用自定义主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用我使用与圆角矩形警告对话框theme.But它有alertdialog矩形和我theme.My的问题是如何更换警告对话框边框喜欢dialog.I要显示,只有自己的主题这一组项目。

In my application i am using alert dialog with rounded rectangle theme.But it have alertdialog rectangle and my theme.My problem is how to replace alert dialog border like dialog.I want to show this set item with own theme only.

我要输出这种方式代替上面的主题:

I want output this manner instead of the above theme:

主要活动:

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) {
                }
                 });

我的主题:

<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>

推荐答案

使用对话,而不是AlertDialog。

Use Dialog instead of AlertDialog.

创建要在对话框setContent对话框,显示您的自定义布局。在对话框中,它会隐藏边框应用这个主题 android.R.style.Theme_Translucent_NoTitleBar

Create your custom layout which you want to show in dialog and setContent in dialog.Apply this theme android.R.style.Theme_Translucent_NoTitleBar in dialog it will hide border.

下面是一个示例code。

Here is sample code.

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();

更新:

只是想这在AlertDialog。

just tried this in AlertDialog.

AlertDialog.Builder alertSeverity = new AlertDialog.Builder(
           getActivity(), android.R.style.Theme_Translucent_NoTitleBar);

这篇关于删除警报对话框边框使用自定义主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 22:24