Android activity as dialog, but without a title bar

AndroidWebviewTitlebar

Android Problem Overview


I have an activity that has the following set as theme:

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

However, there is a title bar in the activity-dialog that appears, that uses up the little available space that I have. How can I remove it?

Android Solutions


Solution 1 - Android

Try doing requestWindowFeature(Window.FEATURE_NO_TITLE); in onCreate. It'll need to be done immediately after calling super.onCreate and just before setContentView.

Solution 2 - Android

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

Try this

supportRequestWindowFeature(Window.FEATURE_NO_TITLE);

immediately before setContentView(R.layout.MyDialogActivity);

Solution 3 - Android

You can define your own theme:

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

(Tip of the hat to @Rehan) If you're using the compatibility library, you should pick an AppCompat parent theme and leave off the android: prefix. For example:

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

Solution 4 - Android

If you are using AppCompatActivity in which you are forced to use Theme.AppCompat.xxx for everything, you can remove the dialog title or actionbar in styles.xml using this:

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

Notice the use of name="windowActionBar", instead of name="android:windowActionBar".

Solution 5 - Android

If you are using AppCompatActivity requestWindowFeature(Window.FEATURE_NO_TITLE) is not working.

for this you can create custom theme in values/style.xml as below:

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

please note that item name:"windowNoTitle" not item name:"android:windowNoTitle"

In menifest.xml apply this custom theme as

<activity android:name=".activity.YourActivity"
            android:theme="@style/NoTitleDialog"/>

or you can use getSupportActionBar().hide() to programmatically hide action bar.

Solution 6 - Android

This one worked for me for appcompat.

<style name="DialogTheme" parent="Theme.AppCompat.Light.Dialog">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

Solution 7 - Android

This one worked for me.

I was able to disable the title

style.xml

<style name="AppDialogScreenTheme" parent="Base.Theme.MaterialComponents.Light.Dialog">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

AndroidManifest.xml

  <activity
        android:name=".MyActivity"
        android:theme="@style/AppDialogScreenTheme">

  </activity>

Solution 8 - Android

for dialogs, you can do it like:

Dialog dialog = new Dialog(context);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

Solution 9 - Android

This works for me, may it helps someone too :

style.xml

<style name="NoTitleActivityDialog" parent="Theme.AppCompat.Light.Dialog.Alert">
    <item name="windowNoTitle">true</item>
</style>

AndroidManifest.xml

   <activity
        android:name=".DialogActivity"
        android:theme="@style/NoTitleActivityDialog"/>

Solution 10 - Android

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionShadeView Question on Stackoverflow
Solution 1 - AndroidFemiView Answer on Stackoverflow
Solution 2 - AndroidzackygauravView Answer on Stackoverflow
Solution 3 - AndroidTed HoppView Answer on Stackoverflow
Solution 4 - AndroidNeohView Answer on Stackoverflow
Solution 5 - AndroidSangram HaladkarView Answer on Stackoverflow
Solution 6 - AndroidAjjiView Answer on Stackoverflow
Solution 7 - AndroidJavid SattarView Answer on Stackoverflow
Solution 8 - AndroidAnhSirk DasarpView Answer on Stackoverflow
Solution 9 - AndroidKapil RajputView Answer on Stackoverflow
Solution 10 - Androidjenos konView Answer on Stackoverflow