简体   繁体   中英

Why does Android AlertDialog go full screen?

If I pass an empty array to setItems , my AlertDialog goes full screen on an emulator running Android 9. However, on my device running Android 5.1, it does not go full screen, which is the behavior I am trying to achieve.

What could be causing the AlertDialog to go full screen on the emulator running Android 9, but not on the device running Android 5.1?

This is how I set up my 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();

Here it is on the emulator:

在此处输入图片说明

EDIT: This how it looks on my device running Android 5.1.

在此处输入图片说明

根据需要使用以下设置宽度和高度

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM