WindowManager m = getWindowManager();
Display d = m.getDefaultDisplay(); //为获取屏幕宽、高
LayoutParams p = getWindow().getAttributes(); //获取对话框当前的参数值
p.height = (int) (d.getHeight() * 0.6); //高度设置为屏幕的0.6
p.width = (int) (d.getWidth() * 0.95); //宽度设置为屏幕的0.95
getWindow().setAttributes(p); //设置生效
1 WindowManager m = getWindowManager(); 2 Display d = m.getDefaultDisplay(); //为获取屏幕宽、高
3
4 LayoutParams p = getWindow().getAttributes(); //获取对话框当前的参数值
5
6 p.height = (int) (d.getHeight() * 0.6); //高度设置为屏幕的0.6
7
8 p.width = (int) (d.getWidth() * 0.95); //宽度设置为屏幕的0.95
9
10 getWindow().setAttributes(p); //设置生效