I have an AlertDialog including an .setMultiChoiceItems. I set the size of the dialog box to fill 90% of the screen, but when the dialog is displayed, the buttons are still near the top of the dialog and cut of the options in the Content Area. I can scroll to see all the options, but it would obviously be better if the content area was expanded to show more of them initially.
This is the code I used, as for as I can tell, it's the pretty standard way to display an alert dialog? multiFileNames is an array containing the texts to display, noOfOptions is the number of items in that array.
AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
alt_bld.setTitle("Select Items to Share");
boolean[] checkedItems = new boolean[noOfOptions];
alt_bld.setMultiChoiceItems(multiFileNames, checkedItems, (dialog, which, isChecked) -> checkedItems[which] = isChecked);
alt_bld.setPositiveButton("Select", (dialog, which) -> {
//process selected, missed this out as it's quite long.
dialog.dismiss();// dismiss the alertbox after chose option
});
alt_bld.setNegativeButton("Cancel", (dialog, which) -> {
dialog.dismiss();
finish();
});
AlertDialog alert = alt_bld.create();
alert.show();
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
layoutParams.copyFrom(alert.getWindow().getAttributes());
// setting width to 90% of display
layoutParams.width = (int) (displayMetrics.widthPixels * 0.9f);
// setting height to 90% of display
layoutParams.height = (int) (displayMetrics.heightPixels * 0.9f);
alert.getWindow().setAttributes(layoutParams);

AlertDialog isn't meant to be used this way. The best thing you can do is stop fighting the system and let it display the size it thinks it needs to display. It's design is not to take a fixed percentage of the screen. And truthfully a big empty screen with buttons at the bottom isn't a good mobile design.
If you can't for some reason, you shouldn't use AlertDialog. Use Dialog, and you an customize it as you wish.