从AlertDialog删除顶部填充?

343*_*43N 3 android android-alertdialog

因此,我制作了一个AlertDialog,由于某种原因,使用默认的Android lollipop +主题在AlertDialog上放置了一个讨厌的顶部填充,我不知道该如何编辑/删除它。

这是我用来生成AlertDialog的代码

AlertDialog.Builder builder;
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                builder = new AlertDialog.Builder(this, android.R.style.Theme_Material_Dialog_Alert);
            } else {
                builder = new AlertDialog.Builder(this);
            }
            builder.setTitle("Found corrupted files")
                    .setMessage("We've found " + count + " images that are either missing or " +
                            "corrupt. Should we remove these entries from the list?")
                    .setPositiveButton("Yeah", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface d, int i) {
                            MainActivity.this.removeCorruptedImages();
                            d.cancel();
                        }
                    })
                    .setNegativeButton("No", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface d, int i) {
                            d.cancel();
                        }
                    })
                    .setIcon(R.drawable.ic_warning_white_24dp);

            AlertDialog al = builder.create();
            al.show();
Run Code Online (Sandbox Code Playgroud)

它产生了这个: 在此处输入图片说明

我想摆脱标题上方的空白/空白。

小智 5

在显示AlertDialog之前,请尝试以下行

AlertDialog al = builder.create(); al.requestWindowFeature(Window.FEATURE_NO_TITLE); al.show();