簡體   English   中英

Android彈出窗口全屏

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM