Remove top shim from AlertDialog?

So, I made an AlertDialog, and this nasty top overlay on my AlertDialog for some reason uses the standard Lollipop + Android theme and I can't figure out how to edit / get rid of it.

Here's the code I'm using to create the 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();

      

And it produces this: enter image description here

I want to get rid of that space / space above the title.

+3


source to share


2 answers


Just try this line before showing your AlertDialog



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

+4


source


Have you tried setting the spacing between views like this:



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

+2


source







All Articles