【问题标题】:How do you get the "dim amount" of a Window?你如何得到一个窗口的“微量”?
【发布时间】:2021-04-08 13:51:13
【问题描述】:

Android 有一个 Window 类,可以让我们设置窗口后面的暗淡量。

public void setDimAmount (float amount)

虽然有“set”功能,但没有“get”功能来检查现有的暗淡量。

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

【问题讨论】:

    标签: android user-interface window material-design


    【解决方案1】:

    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;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多