如何将屏幕隐藏在对话后面
我有一个密码对话,为了防止“偷看”,我想将屏幕隐藏在窗口后面。
我能想到的最好的方法是使用以下代码来模糊屏幕内容:
Window window = dialog.getWindow();
LayoutParams layoutParams = window.getAttributes();
layoutParams.dimAmount = 1.0f;
layoutParams.flags = layoutParams.flags | WindowManager.LayoutParams.FLAG_BLUR_BEHIND;
window.setAttributes(layoutParams);
不幸的是,虽然这在大多数设备上都可以正常工作,但在某些摩托罗拉设备上,这会导致屏幕速度严重减慢,甚至导致密码输入字段无法显示。无法使用。 (是的,我验证了这就是原因,因为删除模糊代码可以修复速度减慢的问题。)
无论如何,我想找到一种方法使对话框后面的屏幕变为空白(或任何纯色)。我一直无法找到解决方案。
I have a Password Dialogue and, to prevent "peeking", I would like to hide the screen behind the window.
The best I could come up with was the following code to Blur the screen's contents:
Window window = dialog.getWindow();
LayoutParams layoutParams = window.getAttributes();
layoutParams.dimAmount = 1.0f;
layoutParams.flags = layoutParams.flags | WindowManager.LayoutParams.FLAG_BLUR_BEHIND;
window.setAttributes(layoutParams);
Unfortunately, while this works fine on the majority of devices, on certain Motorola devices this causes a terrible slowdown of the screen composing to the point where the password entry field is unusable. (Yes, I verified this is the cause, as removing the blurring code fixes the slowdown.)
Anyways, I would like to find a way to make the screen behind the dialog blank (or any solid color). I had been unable to find a solution to this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不为您的密码输入创建一个新的全屏活动呢?然后你就可以把它变成你想要的样子。它真的必须是一个对话框吗?如果是这样,则启动全屏“纯色”活动,然后显示对话框。
Why not just create a new full screen activity for your password entry? Then you can make it look however you want. Does it really have to be a dialog? If so, then start up a full screen "solid color" activity and then show the dialog.