自定义屏幕变暗与对话自定义、屏幕、变暗

2023-09-04 23:21:33 作者:狂傲゛俯视全世界

在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);

Blurring因为API14 是德precated:

Blurring is deprecated since API14:

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

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

 
精彩推荐