Skip to content Skip to sidebar Skip to footer

How To Remove Extra Space In Android List Alert Dialog

I am trying to display sample alert dialog with single choice items and facing problem with extra space after end of the list. Here is my code final CharSequence[] items = {'Red',

Solution 1:

You can have your own dialog layout (see docs), but I'd suggest to leave it as is, as this dialog will look differently on HC/ICS/JB, so tweaking its look is quite bad idea as on other versions of android it may look different. It's just the way OS does it. Leave it is my advice.

Solution 2:

I had been facing a similar issue when I had build the custom alert dialog. In order to address the issue, I had to use theme to get rid of remaining spaces. Following is the code that I had followed:

private Dialog getCustomDialog() {
      AlertDialog.Builderbuilder=newAlertDialog.Builder(this, android.R.style.Theme_DeviceDefault_Panel);
      AlertDialogdialog= builder.create();
      dialog.setView(dialogView, 0, 0, 0, 0);
      return dialog;
    }

As per the documentation here the usage of android.R.style.Theme_DeviceDefault_Panel is followed:

This removes all extraneous window decorations, so you basically have an empty rectangle in which to place your content. It makes the window floating, with a transparent background, and turns off dimming behind the window.

Post a Comment for "How To Remove Extra Space In Android List Alert Dialog"