本文介绍了全宽对话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我什么对话框来掩盖整个屏幕宽度。
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;更多推荐
全宽对话
发布评论