How to create a DialogFragment without title?

Just add this line of code in your HelpDialog.onCreateView(...)

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

This way you’re explicitly asking to get a window without title 🙂

EDIT

As @DataGraham and @Blundell pointed out on the comments below, it’s safer to add the request for a title-less window in the onCreateDialog() method instead of onCreateView(). This way you can prevent ennoying NPE when you’re not using your fragment as a Dialog:

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
  Dialog dialog = super.onCreateDialog(savedInstanceState);

  // request a window without the title
  dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
  return dialog;
}

Leave a Comment