我想为全屏
创建一个弹出窗口我使用了以下内容:
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);
这涵盖了操作栏,但不是全屏..
api 11+也支持LayuotParams.WRAP_CONTENT。我需要解决方案从api级别8开始工作。
答案 0 :(得分:9)
对于全屏,您必须传递MATCH_PARENT
参数而不是WRAP_CONTENT
pwindow = new PopupWindow(layout,LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,true);
答案 1 :(得分:0)
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);
科林版本:
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)