【发布时间】:2012-05-03 13:15:10
【问题描述】:
我想显示设备屏幕大小的警告对话框。我通过此链接How to make an alert dialog fill 90% of screen size? 获得了解决方案,我使用了那里给出的解决方案,它工作得很好,但我的警报消息以非常小的尺寸显示。我们甚至无法以横向方式识别信息。我使用了以下代码。
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.app_description).setPositiveButton(
"Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
builder.Title(title);
Dialog d = builder.setView(new View(this)).create();
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(d.getWindow().getAttributes());
lp.width = WindowManager.LayoutParams.FILL_PARENT;
lp.height = WindowManager.LayoutParams.FILL_PARENT;
d.show();
d.getWindow().setAttributes(lp);
如何设置消息,使其正确显示在对话窗口中?
提前致谢 普什帕
【问题讨论】:
-
它在我的手机中几乎占据了 90%。您从中调用的警报对话框的父级是什么? .
-
“确定”按钮恰到好处,即它位于窗口底部。唯一的问题是没有收到设置为构建器类的消息。
标签: android android-layout dialog android-alertdialog