'How to remove the title in Dialog?

I created an Activity as a dialog using the code below which I put in my manifest. But the problem is it has Title bar, how can I remove it?

android:theme="@android:style/Theme.Dialog"


Solution 1:[1]

Use This Code

final Dialog dialog = new Dialog(context);
    dialog.getWindow();
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);       
    dialog.setContentView(R.layout.yourlayout);
    dialog.show();

Solution 2:[2]

For Me following worked :

<style name="MyActivityDialogTheme" parent="Base.Theme.AppCompat.Light.Dialog">
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowActionBar">false</item>
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

Solution 3:[3]

Use this code when creating a dialog:

requestWindowFeature(Window.FEATURE_NO_TITLE);

Solution 4:[4]

For those who are using AppCompatActivity, above answers may not work.

Try this

supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
immediately before setContentView(R.layout.my_dialog_activity);

Solution 5:[5]

this is work for me

<?xml version="1.0" encoding="utf-8"?>
<resources>
 <style name="mydialogstyle" parent="android:style/Theme.Dialog">
        <item name="android:windowBackground">@null</item>
        <item name="android:windowNoTitle">true</item>
    </style>
</resources>

and this

requestWindowFeature(Window.FEATURE_NO_TITLE);

Solution 6:[6]

Remove Title Bar from Activity extending ActionBarActivity or AppcompatActivity with Dialog Theme

<style name="Theme.MyDialog" parent="@style/Theme.AppCompat.Light.Dialog">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

Solution 7:[7]

It work for me:

In the onCreate() of my custom Dialog Activity:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_alert_dialogue);

    //your code....

}

Manifest:

<activity android:name=".AlertDialogue"
            android:theme="@style/AlertDialogNoTitle">
</activity>

Style:

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

Solution 8:[8]

Handler _alerthandler = new Handler();
    Runnable _alertrunnable = new Runnable() {
        @Override
        public void run() {
            // TODO Auto-generated method stub
            ProfileActivity.this.runOnUiThread(new Runnable() {
                public void run() {
                    // Create custom dialog object
                    final Dialog dialog = new Dialog(ProfileActivity.this);
                    // Include dialog.xml file
                    dialog.getWindow();
                    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                    dialog.setContentView(R.layout.alertbox);
                    TextView title = (TextView) dialog
                            .findViewById(R.id.AlertBox_Title);
                    title.setText(Appconstant.Toast_Title);
                    TextView text = (TextView) dialog
                            .findViewById(R.id.AlertBox_Msg);
                    text.setText(Appconstant.Toast_Msg);
                    dialog.show();

                    Button declineButton = (Button) dialog
                            .findViewById(R.id.AlertBox_Ok);
                    // if decline button is clicked, close the custom dialog
                    declineButton.setOnClickListener(new OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            // Close dialog
                            dialog.dismiss();
                        }
                    });
                }
            });
        }
    };

Solution 9:[9]

I try requestWindowFeature(Window.FEATURE_NO_TITLE); but not working for me, if you are like me so do this : first Add the following code in your res/values/styles.xml:

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

Pass the theme to your dialog:

Dialog dialog = new Dialog(this, R.style.NoTitleDialog);

that's it very simple

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Zulfiqar
Solution 2 Gaurav Singla
Solution 3 superM
Solution 4
Solution 5 Mostafa Rostami
Solution 6 Jignesh Goyani
Solution 7 V.March
Solution 8 Vela
Solution 9 jenos kon