I can create and display a custom alert dialog just fine but even so I have android:layout_width/height="fill_parent"
in the dialog xml it is only as big as the contents.
What I want is dialog that fills the entire screen except maybe a padding of 20 pixel. Then the image that is part of the dialog would automatically stretch to the full dialog size with fill_parent.
Specifying FILL_PARENT on the dialog window, like others suggested, did not work for me (on Android 4.0.4), because it just stretched the black dialog background to fill the whole screen.
What works fine is using the minimum display value, but specifying it within the code, so that the dialog takes 90% of the screen.
So:
In general only adjusting the width should be sufficient in most cases.
Even simpler just do this:
Well, you have to set your dialog's height and width before to show this ( dialog.show() )
so, do something like this:
Getting this code, i made it some changes:
however, dialog size's could change when the device change its position. Perhaps you need to handle by your own when metrics changes. PD: peekDecorView, implies that layout in activity is properly initialized otherwise you may use
in order to get screen size
Here is a short answer that worked for me (Tested on API 8 and API 19).
The following worked fine for me:
(note: windowMinWidthMajor/Minor as suggested in previous answers didn't do the trick. My dialogs kept changing sizes depending on the content)
and then: