自定义屏幕变暗与对话 [英] Custom screen dim with Dialog

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

问题描述

在Android的,当你弹出一个对话框,在屏幕背后变暗。有什么办法来控制是什么样子?例如使其黯淡或多或少,或使用某种类型的模式?

In Android when you pop up a dialog the screen behind it dims. Is there any way to control what that looks like? For example making it dim more or less or using some kind of a pattern?

推荐答案

是的,确实如此。你可以控制它。

Yes, it is. You can control it.

在创建对话框:

WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();  
lp.dimAmount=0.0f; // Dim level. 0.0 - no dim, 1.0 - completely opaque
dialog.getWindow().setAttributes(lp);

UPD :你甚至可以添加模糊对话框后面:

Upd: you can even add blur behind the dialog:

dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);

<一个href="https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_BLUR_BEHIND">Blurring因为API14 是德precated:

Blurring is deprecated since API14:

此常数德precated在API级别14
  模糊不再支持。

This constant was deprecated in API level 14.
Blurring is no longer supported.

这篇关于自定义屏幕变暗与对话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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