- AlertDialog dialog = builder.create();
- dialog.setView(view);
- dialog.show();
- WindowManager m = getWindowManager();
- Display d = m.getDefaultDisplay(); //为获取屏幕宽、高
- android.view.WindowManager.LayoutParams p = dialog.getWindow().getAttributes(); //获取对话框当前的参数值
- p.height = (int) (d.getHeight() * 0.3); //高度设置为屏幕的0.3
- p.width = (int) (d.getWidth() * 0.5); //宽度设置为屏幕的0.5
- dialog.getWindow().setAttributes(p); //设置生效
android对AlertDialog对话框设定高度和宽度
最新推荐文章于 2024-05-27 15:37:02 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)