从AlertDialog中删除顶部填充?

时间:2017-06-12 20:46:38

标签: android alertdialog

因此我使用默认的Android棒棒糖+主题制作了一个AlertDialog并且我的AlertDialog上有这个令人讨厌的顶部填充,我无法弄清楚如何编辑它/摆脱它。 / p>

这是我用来制作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();

它产生了这个: enter image description here

我想摆脱标题上方的填充/空白区域。

2 个答案:

答案 0 :(得分:4)

在显示AlertDialog

之前,请尝试此行

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

答案 1 :(得分:2)

您是否尝试像这样设置视图间距:

a1.setView(View view, int viewSpacingLeft, int viewSpacingTop, int viewSpacingRight, int viewSpacingBottom)