@Override
protected Dialog onCreateDialog(int id) {
//all other dialog stuff (which dialog to display)
//this line is what you need:
dialog.getWindow().setFlags(LayoutParams.FLAG_FULLSCREEN, LayoutParams.FLAG_FULLSCREEN);
return dialog;
}
EDIT Until such time as StackOverflow allows us to version our answers, this is an answer that works for Android 3 and below. Please don't downvote it because it's not working for you now, because it definitely works with older Android versions.
You should only need to add one line to your onCreateDialog() method:
@Override
protected Dialog onCreateDialog(int id) {
//all other dialog stuff (which dialog to display)
//this line is what you need:
dialog.getWindow().setFlags(LayoutParams.FLAG_FULLSCREEN, LayoutParams.FLAG_FULLSCREEN);
return dialog;
}
发布评论
评论(5)
试试这个。
try this.
尝试
try
基于此链接,正确的答案(我自己测试过)是:
把这个对话框的构造函数或
onCreate()
方法中的代码:此外,将对话框的样式设置为:
这可以通过构造函数实现,例如:
编辑:所有的替代方法上面的内容是将样式设置为
android.R.style.ThemeOverlay
就是这样。EDIT2:要支持材质库,请将 Gradle 依赖项添加到 app(module)
build.gradle
文件,然后将对话框的主题设置为
R.style.ThemeOverlay_MaterialComponents
based on this link , the correct answer (which i've tested myself) is:
put this code in the constructor or the
onCreate()
method of the dialog:in addition , set the style of the dialog to :
this could be achieved via the constructor , for example :
EDIT: an alternative to all of the above would be to set the style to
android.R.style.ThemeOverlay
and that's it.EDIT2: To support material library, add Gradle dependency to app(module)
build.gradle
fileThen set dialog's theme to
R.style.ThemeOverlay_MaterialComponents
我发现的最简单的方法
The easiest way I found
编辑 在 StackOverflow 允许我们对答案进行版本控制之前,这是适用于 Android 3 及更低版本的答案。请不要否决它,因为它现在不适合你,因为它肯定适用于旧的 Android 版本。
您只需在
onCreateDialog()
方法中添加一行:EDIT Until such time as StackOverflow allows us to version our answers, this is an answer that works for Android 3 and below. Please don't downvote it because it's not working for you now, because it definitely works with older Android versions.
You should only need to add one line to your
onCreateDialog()
method: