How to remove Alert dialog Title bar

I am following this code to create custom dialog but i am not getting how to remove dialog title bar ?

  AlertDialog alertDialog;

   @Override
   protected Dialog onCreateDialog(int id) {

      AlertDialog dialogDetails = null;

      switch (id) {
      case DIALOG_LOGIN:

       LayoutInflater inflater = LayoutInflater.from(this);
       View dialogview = inflater.inflate(R.layout.dialog_layout, null);

           AlertDialog.Builder dialogbuilder = new AlertDialog.Builder(this);
           dialogbuilder.setTitle("Login");
           dialogbuilder.setView(dialogview);
           dialogDetails = dialogbuilder.create();

           break;
          }

      return dialogDetails;
     }

     @Override
     protected void onPrepareDialog(int id, Dialog dialog) {

      switch (id) {
      case DIALOG_LOGIN:
      alertDialog = (AlertDialog) dialog;

      .......

}

I know to remove title area of the Alert Dialog, we have to use requestWindowFeature(Window.FEATURE_NO_TITLE);

  • What is cursor.setNotificationUri() used for?
  • android listview item style?
  • Is Fragment.setUserVisibleHint() called by the android System?
  • How to Build a RSS reader for Android?
  • What is the `Authorization` part of the http post request of Google's Firebase Downstream message?
  • Applying Effects on Video being Played
  • But don’t know where i have to place above line ?

  • String.equals() with multiple conditions (and one action on result)
  • Change remoteView ImageView background
  • How to add external jar libraries to an android project from the command line
  • Fragment transaction animation: slide in and slide out
  • How to set part of text to bold when using AlertDialog.setMessage() in Android?
  • Robolectric and IntentServices
  • 8 Solutions collect form web for “How to remove Alert dialog Title bar”

    If you don’t want title bar in alert dialog then just remove below line from code.

    dialogbuilder.setTitle("Login");
    

    If still not working then add below line.

    dialogbuilder.requestWindowFeature(Window.FEATURE_NO_TITLE);
    

    Use dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); before dialog.setContentView(R.layout.logindialog); by doing so you will be able to hide the Dialog‘s title.

    Use dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

    First remove this line:

    dialogbuilder.setTitle("Login");
    

    Then add this one:

    dialogbuilder.requestWindowFeature(Window.FEATURE_NO_TITLE);
    

    Try this::

    AlertDialog.Builder builder;
    AlertDialog alertDialog;
    
    Context mContext = getApplicationContext();
    LayoutInflater inflater = (LayoutInflater)
            mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.custom_dialog,
            (ViewGroup) findViewById(R.id.layout_root));
    
    TextView text = (TextView) layout.findViewById(R.id.text);
    text.setText("Hello, this is a custom dialog!");
    ImageView image = (ImageView) layout.findViewById(R.id.image);
    image.setImageResource(R.drawable.android);
    
    builder = new AlertDialog.Builder(mContext);
    builder.setView(layout);
    alertDialog = builder.create();
    

    Refer here

    just remove

    dialogbuilder.setTitle("Login");
    

    I could not find .requestWindowFeature with AlertDialog Builder.

    If you do not want to have a title when constructing an Alert Dialog with a Builder, use new AlertDialog.Builder(getContext(), android.R.style.Theme_Material_Light_Dialog_NoActionBar_MinWidth);

    Use this

    AlertDialog.Builder dialogbuilder = new AlertDialog.Builder(this);
               dialogbuilder .requestWindowFeature(Window.FEATURE_NO_TITLE);
               dialogbuilder.setView(dialogview);
               dialogDetails = dialogbuilder.create();
    
    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.