Matthias Matthias - 1 year ago 41
Android Question

How can I get a Dialog style activity window to fill the screen?

I am using an activity with the dialog theme set, and I want it to be full screen. I tried all sorts of things, even going through the WindowManager to expand the window to full width and height manually, but nothing works.

Apparently, a dialog window (or an activity with the dialog theme) will only expand according to its contents, but even that doesn't always work. For instance, I show a progress bar circle which has width and height set to FILL_PARENT (so does its layout container), but still, the dialog wraps around the much smaller progress bar instead of filling the screen.

There must be a way of displaying something small inside a dialog window but have it expand to full screen size without its content resizing as well?

Answer Source

I found the solution:

In your activity which has the Theme.Dialog style set, do this:

public void onCreate(Bundle savedInstanceState) {


    getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

It's important that you call Window.setLayout() after you call setContentView(), otherwise it won't work.