我们可以在代码中完成对窗体透明度(这是窗体本身的透明度,非背景)的设置,方法如下:

        WindowManager.LayoutParams windowLP = getWindow().getAttributes();
        windowLP.alpha = 0.5f;
        getWindow().setAttributes(windowLP);

alpha在0.0f到1.0f之间。1.0f 代表完全不透明,0.0f 是完全透明

也可以对窗体设置其灰度       
  	WindowManager.LayoutParams windowLP = getWindow().getAttributes();
        windowLP.dimAmount = 0.5f;
        getWindow().setAttributes(windowLP);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);

dimAmount在0.0f和1.0f之间,0.0f完全不暗,1.0f全暗

参考资料:


相关文章:

  • 2022-01-13
  • 2021-10-15
  • 2022-12-23
  • 2021-09-04
  • 2022-12-23
  • 2021-08-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-20
  • 2022-12-23
  • 2021-12-21
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案