tags:

views:

327

answers:

2

I'd like to show a Dialog that occupies as much screen space as possible.

So, here's a sample:

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);

Problem is, this doesn't change a thing. Why?

TIA.

+1  A: 

I don't know how to do exactly what you're wanting, but isn't this mostly defeating the purpose of a Dialog? Why not just create a custom Activity and use the Dialog theme if you're just wanting it to look dialog-ey.

fiXedd
Because of the overhead and the fact that this dialog is a part of an activity.
alex
A: 

You need to change the window layout parameters AFTER setContentView. Anything you do to the window before then (size/location-wise) will be tossed out when you call setContentView.

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

Pierre-Luc Paour