Android activity as dialog, but without a title bar

后端 未结 9 1795
暗喜
暗喜 2020-12-02 21:59

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

相关标签:
9条回答
  • 2020-12-02 22:37

    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>
    
    0 讨论(0)
  • 2020-12-02 22:40

    for dialogs, you can do it like:

    Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    
    0 讨论(0)
  • 2020-12-02 22:44

    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"/>
    
    0 讨论(0)
提交回复
热议问题