Sun Sun - 1 year ago 61
Android Question

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);


But don't know where i have to place above line ?

Answer Source

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);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download