Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fragment Dialog landscape, fill screen

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.

like image 624
Boldijar Paul Avatar asked Dec 06 '14 19:12

Boldijar Paul


1 Answers

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.

like image 65
Boldijar Paul Avatar answered Sep 26 '22 00:09

Boldijar Paul