简体   繁体   中英

Resizing the alert dialog box in android

I need to re-size my alert dialog box to a custom height and width. How would I be able to do this by code so I could set it up with my screen height and width variables?

alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

taken from this post here: How to resize AlertDialog on the Keyboard display

Also you might want to take a look at this one too Resize AlertDialog to fit image exactly

Alternatively if you cannot find a solution it might be best to think about making it an activity rather than an alert dialog

look, i used to have that problem, i could resolve this problem with this code:

Well, you have to set your dialog's height and width before to show this ( dialog.show() ) so, do something like this:

dialog.getWindow().setLayout(width, height);

//then
dialog.show()

On your .xml file use relative layout to auto maximizes to how big the dialog could be. Also you can manipulate data inside the relative layout much more easier if you customize your screen accordingly on the graphic end. I hope this helps someone who may encounter my problem.

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