WindowManager m = getWindowManager(); Display d = m.getDefaultDisplay(); //为获取屏幕宽、高 android.view.WindowManager.LayoutParams p = dialog.getWindow().getAttributes(); //获取对话框当前的参数值 p.height = (int) (d.getHeight() ); //高度设置为屏幕的 p.width = (int) (d.getWidth()); //宽度设置为屏幕的 dialog.getWindow().setAttributes(p); //设置生效
这样设置并没有作用。
InfoDialog infoDialog = new InfoDialog(context, R.style.ResultErrDialog);
WindowManager.LayoutParams lp = infoDialog.getWindow().getAttributes();
infoDialog.getWindow().setGravity(Gravity.BOTTOM);
Window win = infoDialog.getWindow();
win.getDecorView().setPadding(0, 0, 0, 0);
lp.width = WindowManager.LayoutParams.FILL_PARENT;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
win.setAttributes(lp);
infoDialog.show();
这样Dialog 跟屏幕一样的宽
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-10-27 09:51:32