Android: How to create a Dialog without a title?


I'm trying to generate a custom dialog in Android. I create my Dialog like this:

dialog = new Dialog(this);

Everythings works fine except for the title of the Dialog. Even if I don't set the title of the dialog the dialog popup has a blank space at the position of the dialog.

Is there any way to hide this part of the Dialog?

I tried it with an AlertDialog but it seems the layout is not set properly:

LayoutInflater inflater = 
    (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.map_dialog, null);

AlertDialog.Builder builder = new AlertDialog.Builder(this);

// dialog = new Dialog(this);
// dialog.setContentView(R.layout.map_dialog);

dialog = builder.create();

((TextView) dialog.findViewById(;

If I use this code I get a null Pointer Exception in the last line. The dialog is not null so the TextView I try to retrieve does not exist.
If I uncomment the part where I use the Dialog Constructor everything works fine but for the title above my dialog layout.

2/5/2014 1:09:33 PM

Accepted Answer

You can hide the title of a dialog using:


Previous version of this answer, which is overcomplicated:

You need to use an AlertDialog. There's a good explanation on the Android Developer's site about custom dialogs.

In very short summary, you do this with code like copied below from the official website. That takes a custom layot file, inflates it, gives it some basic text and icon, then creates it. You'd show it then with

AlertDialog.Builder builder;
AlertDialog alertDialog;

Context mContext = getApplicationContext();
LayoutInflater inflater = (LayoutInflater)
View layout = inflater.inflate(R.layout.custom_dialog,
        (ViewGroup) findViewById(;

TextView text = (TextView) layout.findViewById(;
text.setText("Hello, this is a custom dialog!");
ImageView image = (ImageView) layout.findViewById(;

builder = new AlertDialog.Builder(mContext);
alertDialog = builder.create();

In response to comment:

I assume that TextView with the id nr is in the View you are inflating with View view = inflater..... If so, then you need to change just one bit: instead of dialog.findView... make it view.findView.... Then once you've done that, remember to use, or even without bothering to do builder.create().

7/31/2015 11:25:51 AM

FEATURE_NO_TITLE works when creating a dialog from scratch, as in:

Dialog dialog = new Dialog(context);

But it doesn't work when creating an AlertDialog (or using the Builder), because it already disables the title and use a custom one internally.

I have looked at the SDK sources, and I think that it can't be worked around. So to remove the top spacing, the only solution is to create a custom dialog from scratch IMO, by using the Dialog class directly.

Also, one can do that with a style, eg in styles.xml:

<style name="FullHeightDialog" parent="android:style/Theme.Dialog">
   <item name="android:windowNoTitle">true</item>

And then:

Dialog dialog = new Dialog(context,;

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow