全宽对话 [英] Full width Dialog

查看:172
本文介绍了全宽对话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我什么对话框来掩盖整个屏幕宽度。

I what the Dialog to cover up the whole screen width.

因此:

Dialog dialog = new Dialog(this);
LayoutParams params = dialog.getWindow().getAttributes();
params.height = LayoutParams.MATCH_PARENT;
params.width = LayoutParams.MATCH_PARENT;
dialog.getWindow().setAttributes(params);

但结果是:

跳过是在父布局的按钮(MATCH_PARENT宽度和高度
  和10dp填充和橙色背景)。

Skip is a button in a parent layout (MATCH_PARENT as width and height and 10dp padding and orange background).

即使在这种<一href=\"http://stackoverflow.com/questions/11613825/how-to-create-dialog-which-will-be-full-in-horizontal-dimension#answer-11614063\">answer最后的结果对双方一定差距。

Even in this answer the final result has some gaps on sides.

有没有办法覆盖整个屏幕宽度没有任何差距?

Is there a way to cover the whole screen width without any gaps?

推荐答案

这是为我工作的解决方案是以下内容:

The solution that worked for me was the following:

使用抓斗设备外形尺寸:

Grab the device dimensions using:

WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Point size = new Point();
display.getSize(size);

然后在对话框的宽度设置为屏幕宽度

Then set the width of the dialog to the screen width

params.width = size.x;

这篇关于全宽对话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆