在自定义dialog时,我使用Dialog.setContentView()方法来指定Dialog的布局。按理说dialog的大小应该和指定的布局文件的大小相同,但是为什么最后显示的效果是dialog一直是正方形的?
Dialog的布局文件:
设置Dialog的布局:
LayoutInflater inflater = LayoutInflater.from(mContext);
View view = inflater.inflate(R.layout.dialog, null);
mDialog.setContentView(view);
我使用了自定义的Dialog Style:
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
或者使用
dialog获取window 然后在window中设置宽高
通过这段代码设置自定义dialog的窗口大小。