我怎样才能得到一个对话式的活动窗口以填充屏幕? [英] How can I get a Dialog style activity window to fill the screen?
问题描述
我使用与对话的主题集中的活动,我希望它是全屏显示。我试过各种各样的事情,即使是经过窗口管理器,手动扩大窗口至全屏宽度和高度,但没有任何工程。
I am using an activity with the dialog theme set, and I want it to be full screen. I tried all sorts of things, even going through the WindowManager to expand the window to full width and height manually, but nothing works.
显然,一个对话框窗口(或对话框主题活动)将只根据其内容扩大,但即使这并不总是奏效。举例来说,我显示一个进度条圆其具有高度和宽度设置为FILL_PARENT(这样做它的布局容器),但尽管如此,各地要小得多进度条,而不是填充屏幕的对话框包裹。
Apparently, a dialog window (or an activity with the dialog theme) will only expand according to its contents, but even that doesn't always work. For instance, I show a progress bar circle which has width and height set to FILL_PARENT (so does its layout container), but still, the dialog wraps around the much smaller progress bar instead of filling the screen.
必须有显示小东西里面的对话窗口的方式,但把它扩展到全屏幕大小没有它的内容调整呢?
There must be a way of displaying something small inside a dialog window but have it expand to full screen size without its content resizing as well?
推荐答案
我找到了解决办法:
在你的活动已在 Theme.Dialog
风格设置,做到这一点:
In your activity which has the Theme.Dialog
style set, do this:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_layout);
getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
}
这一点很重要,你叫 Window.setLayout()
的在的你叫的setContentView()
,否则将无法正常工作。
It's important that you call Window.setLayout()
after you call setContentView()
, otherwise it won't work.
这篇关于我怎样才能得到一个对话式的活动窗口以填充屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!