Android Dialog: Removing title bar

后端 未结 13 2191
醉酒成梦
醉酒成梦 2020-11-29 18:24

I have a weird behavior I can\'t pinpoint the source of.

I have my app with the classic

requestWindowFeature(Window.FEATURE_NO_TITLE);
相关标签:
13条回答
  • 2020-11-29 18:50

    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>
    
    0 讨论(0)
  • 2020-11-29 18:50
    **write this before adding view to dialog.**
    

    dialog1.requestWindowFeature(Window.FEATURE_NO_TITLE);

    0 讨论(0)
  • 2020-11-29 18:56

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

    0 讨论(0)
  • 2020-11-29 18:56

    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.

    0 讨论(0)
  • 2020-11-29 18:56

    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);
    
    0 讨论(0)
  • 2020-11-29 18:56

    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.

    0 讨论(0)
提交回复
热议问题