我在全屏显示 DialogFragment 时遇到了一些问题。在我的应用程序中,我有一个片段,当您单击某个按钮时,它会调用一个 DialogFragment。但是 DialogFragment 只是填充了 Fragment 的区域(在操作栏下方)。我希望它像这样填满所有屏幕:http: //img845.imageshack.us/img845/8682/myimage2.png
有什么帮助吗?
public class ItensActivity extends Fragment {
...
public void openDialogItens()
{
dialog = new ItemDialog();
dialog.show(getFragmentManager(), "");
getFragmentManager().executePendingTransactions();
}
public static class ItemDialog extends DialogFragment
{
@SuppressWarnings("deprecation")
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setView(getContentView());
Dialog dialog = builder.create();
dialog.setCanceledOnTouchOutside(true);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(dialog.getWindow().getAttributes());
lp.width = WindowManager.LayoutParams.WRAP_CONTENT;
lp.height = WindowManager.LayoutParams.FILL_PARENT;
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setAttributes(lp);
return dialog;
}
private View getContentView() {
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.popup_item, null);
return view;
}
}