Android activity in dialog, but without title

I have an action that has the following set as a theme:

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

However, in the action dialog that appears, there is a title bar that uses the small available space that I have. How to remove it?

+68
android webview titlebar
Jun 12 2018-11-22T00:
source share
9 answers

Try to execute requestWindowFeature(Window.FEATURE_NO_TITLE); in onCreate . This must be done immediately after calling super.onCreate and immediately before setContentView .

+142
Jun 12 '11 at
source share

For those using AppCompatActivity , the answers above may not work.

Try

supportRequestWindowFeature(Window.FEATURE_NO_TITLE);

just before setContentView(R.layout.MyDialogActivity);

+109
Oct 29 '15 at 14:48
source share

You can define your own theme:

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

(Hint to @Rehan). If you use the compatibility library, you must select the parent theme AppCompat and not android: prefix. For example:

 <style name="NoTitleDialog" parent="@style/Theme.AppCompat.Dialog"> <item name="windowNoTitle">true</item> </style> 
+107
Jun 12 '11 at 10:14
source share

If you are using AppCompatActivity in which you are forced to use Theme.AppCompat.xxx for everyone, you can remove the dialog title or action bar 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> 

Note the use of name="windowActionBar" instead of name="android:windowActionBar" .

+29
Aug 28 '15 at 6:37
source share

If you use AppCompatActivity requestWindowFeature (Window.FEATURE_NO_TITLE) does not work.

To do this, you can create a custom theme in the /style.xml values, as shown below:

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

note that the element name: "windowNoTitle" no element 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 the action bar.

+7
Aug 02 '16 at 12:08 on
source share

This 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> 
+5
May 29 '16 at
source share

for dialogs, you can do it like this:

 Dialog dialog = new Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
+1
Oct 17 '12 at 13:18
source share

This works for me, can this help someone:

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"/> 
0
Jan 6 '17 at 12:43 on
source share

This one worked for me.

I was able to disable the header

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> 
0
Jul 6 '19 at 5:43
source share



All Articles