全宽对话

编程入门 行业动态 更新时间:2024-10-28 21:27:39
本文介绍了全宽对话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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).

即使在这种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;

更多推荐

全宽对话

本文发布于:2023-11-23 04:05:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1620023.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!