[英]Latest Android Studio opening every window or popup in full screen
[英]Android Popup Window Full Screen
我想为全屏创建一个popupwindow
我使用了以下内容:
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开始工作。
对于全屏,您必须传递MATCH_PARENT
参数而不是WRAP_CONTENT
pwindow = new PopupWindow(layout,LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,true);
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版本:
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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.