0

I tried to make my dialog fill in the whole screen. Here's the code:

public void onStart() {
        super.onStart();
        AlertDialog dialog = (AlertDialog)getDialog();

        WindowManager.LayoutParams params = getDialog().getWindow().getAttributes();
        params.width = ViewGroup.LayoutParams.MATCH_PARENT;
        params.height = ViewGroup.LayoutParams.MATCH_PARENT;
        dialog.getWindow().setAttributes(params);
}

The problem is that the height still seems to wrap the content. The width however looks fine. This would be okay, but besides the fact that the height isn't filling the whole screen, the dialog now isn't horizontally centered anymore, but starts at the top edge of the screen.

I already tried params.gravity = Gravity.CENTER without success.

Any ideas on that?

Mazen
  • 203
  • 2
  • 15

0 Answers0