Android 如何在自定义AlertDialog中删除边框?

Android 如何在自定义AlertDialog中删除边框?,android,android-alertdialog,Android,Android Alertdialog,我正在尝试创建带有图像文本和按钮的自定义AlertDialog。当我显示它时,我会看到一个白色的边框,看起来很可怕 我怎样才能摆脱那白色的边界 这里是我的自定义对话框: public LinearLayout customeLL; public void alertD() { AlertDialog ad; AlertDialog.Builder builder; Context mContext = getApplicati

我正在尝试创建带有图像文本和按钮的自定义
AlertDialog
。当我显示它时,我会看到一个白色的边框,看起来很可怕

我怎样才能摆脱那白色的边界

这里是我的自定义对话框:

public LinearLayout customeLL;
    public void  alertD()
    {
        AlertDialog ad;
        AlertDialog.Builder  builder;
        Context mContext = getApplicationContext();
        TextView a = new TextView(getApplicationContext());
        a.setText("Test dialog");
        ImageView img = new ImageView(getApplicationContext());
        img.setBackgroundResource(R.drawable.bottombar_bg);
        LinearLayout customeLL = new LinearLayout(getApplicationContext());
        customeLL.setOrientation(LinearLayout.VERTICAL);
        customeLL.addView(img,curWidth,37);
        customeLL.addView(a,curWidth,37);
        builder = new AlertDialog.Builder(myClass.this);
        builder.setView(customeLL);
        ad=builder.create();
        ad.show();

    }

正如您所看到的,上边框和图像有一个2-3像素的空间。

尝试使用此对话框而不是AlertDialog.Builder

。。用于从对话框中删除边框线

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

如果希望对话框边框以任何颜色显示,则必须使用布局样式和主题。这里有一篇关于它的优秀文章:

这将删除边框:

AlertDialog ad;
ad= new AlertDialog.Builder(context).create();
ad.show();
ad.setContentView(R.layout.dialog_layout); // set your custom layout

// Then initialize your dialog views like this
TextView txt= (TextView) ad.findViewById(R.id.dialog_text); // a TextView inside dialog 
                                                            // layout
txt.setText("I'm a custom dialog!");

另外,我在全屏模式下使用自定义对话框时遇到问题。只要对话没有被取消,我手机的通知栏就会一直出现。使用自定义的AlertDialog,这不会成为问题;)

你说的白钻虫是什么意思?只是个边界。alertDialog中的边框(默认为白色边框)您可以使用Dialog而不是Alert..?当然,如果有,我可以删除文件夹:(。但所有人都说我必须在alertDialog中创建自定义。(用于图像而不是标题)。我只想要垂直样式:图像(而不是标题),text1,text2,text3,btn1,btn2…您可以在对话框中添加任何您想要的布局..谢谢,但它只是删除标题。我需要删除边框:((请参见顶部的图片-白线-可以删除?????我刚刚发布了一个要点,显示了一个带有自定义主题的浮动对话框,没有标题或边框: