How to remove title from AlertDialog in android?

By | July 24, 2012

Hello all..

Today I will show you two simple ways to remove title in an android alertdialog.

Actually you can do this in two methods.

Method 1

That takes a custom layot file, inflates it, gives it some basic text and icon, then creates it.

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

Method 2

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.

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

Leave a Reply

Your email address will not be published. Required fields are marked *