android – How to remove the title of a dialog

Question:

How to call something dialog without ActionBar so that only the layout file is highlighted. The options with hiding / killing the ActionBar \ changing the theme of the Activity “ DialogFragment '' (if possible) will also work.

The attempts I've tried but nothing came out:

  • Make an Activity with themes @android:style/Theme.Dialog.NoTitleBar and @android:style/Theme.NoTitleBar.Dialog .
  • Make an Activity with themes @android:style/Theme.Dialog.NoTitleBar and @android:style/Theme.NoTitleBar.Dialog . Make a DialogFragment , and then remove, hide the 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 options for solving your problem:

  • If using Dialog :

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

     setStyle(STYLE_NO_TITLE, 0);
Scroll to Top