你如何获得 Window 的 "dim amount"?

How do you get the "dim amount" of a Window?

Android 有一个 Window class 让我们设置 window.

后面的暗淡量
public void setDimAmount (float amount)

虽然有“设置”功能,但没有“获取”功能来检查现有的暗淡量。

有人可以告诉我如何“获取”或找出现有或默认的暗淡量吗?

WindowManager.LayoutParams 包含 window 的属性。快速查看源代码可能会有所帮助。

 public void setDimAmount(float amount) {
    final WindowManager.LayoutParams attrs = getAttributes();
    attrs.dimAmount = amount;
    mHaveDimAmount = true;
    dispatchWindowAttributesChanged(attrs);
}

所以当你想获得 dimAmount 时,你可以从 WindowManager.LayoutParams 获得它。

float dimAmount = getWindow().getAttributes().dimAmount;