- 首页 > it技术 > >
android|android window弹出窗
Dialog myDialog = new Dialog(MainActivity.this, R.style.Translucent_NoTitle);
View view = LayoutInflater.from(MainActivity.this).inflate(
R.layout.dialog, null);
myDialog.setContentView(view);
myDialog.setCanceledOnTouchOutside(true);
Window dialogWindow = myDialog.getWindow();
dialogWindow.setGravity(Gravity.CENTER);
//获取屏幕的宽高
WindowManager wm = this.getWindowManager();
int width = wm.getDefaultDisplay().getWidth();
int height = wm.getDefaultDisplay().getHeight();
//设置弹出框的大小
dialogWindow.setLayout(width*5/6,height/3);
//展示弹出
myDialog.show();
- true
- @android:color/transparent
- @null
- true
推荐阅读