android – How to remove the title of the dialog

Question:

How to call something dialog without ActionBar so that only the layout file is displayed. Hiding/killing the ActionBar /changing the theme of the Activity “DialogFragment“ (if possible) would also work.

Attempts I've tried but didn't work:

  • Make an Activity with @android:style/Theme.Dialog.NoTitleBar and @android:style/Theme.NoTitleBar.Dialog .
  • Make an Activity with @android:style/Theme.Dialog.NoTitleBar and @android:style/Theme.NoTitleBar.Dialog . Make DialogFragment , and then remove, hide ActionBar – it turns out that the DialogFragment does not have an ActionBar (at least getActionBar does not work).
  • Make your style with Dialog and NoTitleBar . It didn't work out at all.

Help me please!

Answer:

Here is one of the solutions to your problem:

  • If you are using Dialog :

     Dialog dialog = new Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.my_dialog_la); dialog.show();
  • If you are extending DialogFragment , then add the following line to onCreate :

     setStyle(STYLE_NO_TITLE, 0);
Scroll to Top