android中设置AlertDialog的大小
2015-05-12 17:09
218 查看
[html] view
plaincopyprint?
AlertDialog dialog = builder.setTitle("消息列表")
.setView(layout)
.create();
dialog.show();
//设置窗口的大小
dialog.getWindow().setLayout(300, 200);
dialog.show();一定要放在dialog.getWindow().setLayout(300, 200);的前面,否则不起作用。
网上有一种方法是
[html] view
plaincopyprint?
WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
params.width = 300;
params.height = 200;
dialog.getWindow().setAttributes(params);
但是dialog.getWindow().setLayout(300, 200);实际上封装了这个方法,setLayout()的源代码如下:
[html] view
plaincopyprint?
final WindowManager.LayoutParams attrs = getAttributes();
attrs.width = width;
attrs.height = height;
if (mCallback != null) {
mCallback.onWindowAttributesChanged(attrs);
}
所以这两个方法的作用本质上是一样的,都是为AlertDialog设置大小。
From:http://blog.csdn.net/zwq1457/article/details/8568952
plaincopyprint?
AlertDialog dialog = builder.setTitle("消息列表")
.setView(layout)
.create();
dialog.show();
//设置窗口的大小
dialog.getWindow().setLayout(300, 200);
dialog.show();一定要放在dialog.getWindow().setLayout(300, 200);的前面,否则不起作用。
网上有一种方法是
[html] view
plaincopyprint?
WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
params.width = 300;
params.height = 200;
dialog.getWindow().setAttributes(params);
但是dialog.getWindow().setLayout(300, 200);实际上封装了这个方法,setLayout()的源代码如下:
[html] view
plaincopyprint?
final WindowManager.LayoutParams attrs = getAttributes();
attrs.width = width;
attrs.height = height;
if (mCallback != null) {
mCallback.onWindowAttributesChanged(attrs);
}
所以这两个方法的作用本质上是一样的,都是为AlertDialog设置大小。
From:http://blog.csdn.net/zwq1457/article/details/8568952
相关文章推荐
- android中设置AlertDialog的大小
- android中设置AlertDialog的大小 .
- android中设置AlertDialog的大小 .
- android中设置AlertDialog的大小
- android中设置AlertDialog的大小 .
- Android 设置AlertDialog的大小 .
- android中设置AlertDialog的大小
- android中设置AlertDialog的大小 .
- android中设置AlertDialog的大小 .
- Android 中TabLayout如何设置字体大小!
- android Html.fromHtml font 标签支持设置字体大小和颜色
- [Android] Eclipse Android中设置模拟器屏幕大小几种方法
- android默认字体大小设置
- Android 二维码扫描大小,扫描画面方向,设置前置后置摄像头
- Android动态设置View的位置和大小
- Android——动态设置TextView CompoundDrawable的大小
- Android中TextView通过SpannableString设置字体、大小、颜色、样式、超级链接
- Android中sp使用问题及字体大小跟随系统设置
- android 设置Spinner文字标题颜色 字体大小样式
- Android开发全程记录(七)——bitmap设置图片大小的方法