Android Popup Window Full Screen

喜欢而已 提交于 2019-12-22 04:42:58

问题


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.


回答1:


For the full screen you have to pass the MATCH_PARENT params instead of WRAP_CONTENT

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



回答2:


JAVA Version

 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)


来源:https://stackoverflow.com/questions/24466869/android-popup-window-full-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!