对于普通的Dialog或者AlertDialog,都可以用layout设定match_parent,但是DialogFragment似乎需要代码才能搞定,如下:
@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); } }