为什么Android AlertDialog会全屏显示?

时间:2019-07-17 12:02:46

标签: android android-alertdialog android-dialog

如果我将空数组传递给setItems,则AlertDialog会在运行Android 9的模拟器上全屏显示。但是,在运行Android 5.1的设备上,它不会全屏显示,这是我试图实现的行为。

是什么原因导致AlertDialog在运行Android 9的模拟器上全屏显示,而不是在运行Android 5.1的设备上全屏显示?

这就是我设置AlertDialog的方式:

AlertDialog.Builder builder = new AlertDialog.Builder(ContextActivity);
builder.setTitle(dialogTitel);


builder.setItems(arrayItems, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialogInterface, int item) {

               ...     
            }
         });


final AlertDialog Block = builder.create();
Block.show();

它在模拟器上:

enter image description here

编辑:这是在运行Android 5.1的设备上的外观。

enter image description here

1 个答案:

答案 0 :(得分:0)

在下面使用所需的宽度和高度设置

Block.Show().Window.SetLayout(some_width,some_height);