Maximizing AlertDialog?

I would like to show a Dialog that takes up as much screen space as possible.

So here's an example:

AlertDialog dialog = new AlertDialog.Builder(ctx)......create();
Window w = dialog.getWindow();
WindowManager.LayoutParams lp = w.getAttributes();
lp.width = 320;
lp.height = 480;
w.setAttributes(lp);

      

The problem is that it doesn't change anything. Why?

TIA.

+2


source to share


3 answers


I don't know how to do exactly what you want, but doesn't that basically defeat the purpose of the dialogue? Why not just create a custom activity and use a dialog theme if you just want it to look like a dialog.



+1


source


You need to change AFTER window layout options setContentView. Anything you do in the window before (size / location) will be output when setContentView is called.



http://devstream.stefanklumpp.com/2010/07/android-display-dialogs-in-fullscreen.html

0


source


You need to add minWidth and minHeight attributes in your dialog layout xml file. For example. screen size 800 * 480, then set android:minWidth="800dip"

,android:minHeight="400dip"

0


source







All Articles