Android activity as dialog, but without a title ba

2019-01-11 05:51发布

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?

8条回答
男人必须洒脱
2楼-- · 2019-01-11 06:11

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

Try this

supportRequestWindowFeature(Window.FEATURE_NO_TITLE);

immediately before setContentView(R.layout.MyDialogActivity);

查看更多
Summer. ? 凉城
3楼-- · 2019-01-11 06:12

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>
查看更多
登录 后发表回答