I have a weird behavior I can\'t pinpoint the source of.
I have my app with the classic
requestWindowFeature(Window.FEATURE_NO_TITLE);
create new style in styles.xml
<style name="myDialog" parent="android:style/Theme.Dialog">
<item name="android:windowNoTitle">true</item>
</style>
then add this to your manifest:
<activity android:name=".youractivity" android:theme="@style/myDialog"></activity>
**write this before adding view to dialog.**
dialog1.requestWindowFeature(Window.FEATURE_NO_TITLE);
All the above answer not working for me for AppCompatDialog
If you are using AppCompatDialog try this
Important note: Set this before calling setContentView.
dialog.supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
With next variant I have no reaction:
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); //before
dialog.setContentView(R.layout.logindialog);
So, I try to use next:
dialog.supportRequestWindowFeature(Window.FEATURE_NO_TITLE); //before
dialog.setContentView(R.layout.logindialog);
This variant work excellent.
use below code before setcontentview :-
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.custom_dialog);
Note:- above code must have to use above dialog.setContentView(R.layout.custom_dialog);
In XML use a theme
android:theme="@android:style/Theme.NoTitleBar"
also styles.xml:
<style name="hidetitle" parent="android:style/Theme.Dialog">
<item name="android:windowNoTitle">true</item>
</style>
And then:
Dialog dialog_hidetitle_example = new Dialog(context, R.style.hidetitle);
I am an Android novice and came across this question trying to get rid of a title bar.
I'm using an activity and displaying it as a dialog. I was poking around with themes and came across a useful bit of default theming.
Here's the code from my AndroidManifest.xml
that I was using when the title bar was showing:
<activity
android:name=".AlertDialog"
android:theme="@android:style/Theme.Holo.Dialog"
>
</activity>
Here's the change that got me my desired result:
<activity
android:name=".AlertDialog"
android:theme="@android:style/Theme.Holo.Dialog.NoActionBar"
>
</activity>
As I said, I'm still new to Android, so this may have undesirable side-effects, but it appears to have given me the outcome I wanted, which was just to remove the title bar from the dialog.