Android 弹出窗口全屏

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24466869/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 08:14:26  来源:igfitidea点击:

Android Popup Window Full Screen

androidpopupwindowandroid-fullscreen

提问by mkumar

I want to create a popupwindow for fullscreen

我想为全屏创建一个弹出窗口

i've used the following :

我使用了以下内容:

LayoutInflater inflater = (LayoutInflater) MainActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

layoutt = inflater.inflate(R.layout.loginto,(ViewGroup) findViewById(R.id.window1));

pwindow = new PopupWindow(layoutt,LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,true);

This covers the action bar but not the full screen..

这涵盖了操作栏,但不包括全屏..

Also LayuotParams.WRAP_CONTENT is supported by api 11+ . i need the solution to work from api level 8.

api 11+ 也支持 LayuotParams.WRAP_CONTENT。我需要从 api 级别 8 开始工作的解决方案。

回答by Govind Rathod

For the full screen you have to pass the MATCH_PARENTparams instead of WRAP_CONTENT

对于全屏,您必须传递MATCH_PARENT参数而不是WRAP_CONTENT

pwindow = new PopupWindow(layout,LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,true);

回答by Manohar Reddy

JAVA Version

JAVA版

 View view=getLayoutInflater().inflate(R.layout.dialog_complete_pause_work,null,false);

 PopupWindow popupWindow=new PopupWindow(view, ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT);

 popupWindow.showAtLocation(view, Gravity.CENTER,0,0);

Kotlin Version:

科特林版本:

val view = layoutInflater.inflate(R.layout.your_layout, null, false)

val popupWindow = PopupWindow(view, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)

popupWindow.showAtLocation(view, Gravity.CENTER, 0, 0)