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?
This would be helpful for someone like me. Create custom dialog style:
In
AndroidManifest.xml
file set theme for wanted activity:That is all, no need to call methods programaticaly.
In your manifest file where our activity is defined
without action bar
I found the solution:
In your activity which has the
Theme.Dialog
style set, do this:It's important that you call
Window.setLayout()
after you callsetContentView()
, otherwise it won't work.Matthias' answer is mostly right but it's still not filling the entire screen as it has a small padding on each side (pointed out by @Holmes). In addition to his code, we could fix this by extending Theme.Dialog style and add some attributes like this.
Then we simply declare Activity with theme set to
MyDialog
:Set a minimum width at the top most layout.
For example:
For Dialog This may helpful for someone. I want a dialog to take full width of screen. searched a lot but nothing found useful. Finally this worked for me:
after adding this, my dialog appears in full width of screen.