6

I have a problem with a fragment dialog, if the phone is on portrait mode, everything is ok, the dialog is almost full screen, but when I rotate my phone, in landscape there are some big gaps on the sides..is possible to fix this problem?

enter image description here

I call this

        getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);

To get rid of the DIalogFragment title. I'm using a Linear Layout.

Boldijar Paul
  • 5,405
  • 9
  • 46
  • 94
  • possible duplicate of [Full Screen DialogFragment in Android](http://stackoverflow.com/questions/7189948/full-screen-dialogfragment-in-android) – An SO User Dec 06 '14 at 19:26
  • @LittleChild Do CTRL + F on that question. Tell me if you find the word 'landscape'. Thanks. – Boldijar Paul Dec 06 '14 at 19:29
  • If you only read rather than a CTRL+F `android:layout_width="fill_parent" android:layout_height="fill_parent"` – An SO User Dec 06 '14 at 19:55

1 Answers1

4

The solution:

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

Add this to your dialog fragment.

Boldijar Paul
  • 5,405
  • 9
  • 46
  • 94