Android 创建没有标题栏的对话框

来源:互联网 发布:火车头采集器 织梦5.7 编辑:程序博客网 时间:2024/05/29 14:27

FEATURE_NO_TITLE works when creating a dialog from scratch, as in:

Dialog dialog = new Dialog(context);dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

But it doesn't work when creating an AlertDialog (or using the Builder), because it already disables the title and use a custom one internally.

I have looked at the SDK sources, and I think that it can't be worked around. So to remove the top spacing, the only solution is to create a custom dialog from scratch IMO, by using the Dialog class directly.

Also, one can do that with a style, eg in styles.xml:

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

And then:

Dialog dialog = new Dialog(context, R.style.FullHeightDialog);

原创粉丝点击