Full Screen DialogFragment in Android

I’m trying to show an almost fullscreen DialogFragment. But I’m somehow not able to do so.

The way I am showing the Fragment is straight from the android developer documentation

FragmentManager f = ((Activity)getContext()).getFragmentManager();
FragmentTransaction ft = f.beginTransaction();
Fragment prev = f.findFragmentByTag("dialog");
if (prev != null) {

// Create and show the dialog.
DialogFragment newFragment = new DetailsDialogFragment();
newFragment.show(ft, "dialog");

I know naively tried to set the RelativeLayout in the fragment to fill_parent and some minWidth and minHeight.


I would know expect the DialogFragment to fill the majority of the screen. But I only seems to resize vertically but only until some fixed width horizontally.

I also tried to set the Window Attributes in code, as suggested here: http://groups.google.com/group/android-developers/browse_thread/thread/f0bb813f643604ec. But this didn’t help either.

I am probably misunderstanding something about how Android handles Dialogs, as I am brand new to it. How can I do something like this? Are there any alternative ways to reach my goal?

Android Device:
Asus EeePad Transformer
Android 3.0.1

I now managed to get it into full screen, with the following code in the fragment

public void onCreate(Bundle savedInstanceState) {
    setStyle(STYLE_NO_FRAME, android.R.style.Theme_Holo_Light);

Unfortunately, this is not quite want I want. I definitely need a small “padding” around the dialog to show the background.

Any ideas how to accomplish that?

31 Answers

To get DialogFragment on full screen

Override onStart of your DialogFragment like this:

public void onStart()
    Dialog dialog = getDialog();
    if (dialog != null)
        int width = ViewGroup.LayoutParams.MATCH_PARENT;
        int height = ViewGroup.LayoutParams.MATCH_PARENT;
        dialog.getWindow().setLayout(width, height);

And thanks very much to this post: The-mystery-of-androids-full-screen-dialog-fragments

Leave a Comment