Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

安卓12默认支持Background blur以及Blur behind,希望可以适配一下 #493

Open
AweiLoveAndroid opened this issue Jun 2, 2023 · 1 comment

Comments

@AweiLoveAndroid
Copy link

Android12默认支持在Activity和Dialog中可以实现高斯模糊效果,相关api如下:

设置窗口本身模糊:

  • 调用 Window#setBackgroundBlurRadius(int) 设置背景模糊处理半径。
  • 调用 Window#setBackgroundDrawableResource(int) 添加具有半透明颜色的矩形窗口背景可绘制对象。

设置背景模糊:

  • 选择一个互补的暗度。Window#setDimAmount(float amount)
  • 调用 WindowManager.LayoutParams#setBlurBehindRadius 设置“模糊处理后方屏幕”的半径。

结合View使用:

// 大致代码如下:
View decorView = getWindow().getDecorView();
decorView.setRenderEffect(RenderEffect.createBlurEffect(25F, 25F, Shader.TileMode.CLAMP));
View popContentsView = Layoutinfalter.from(context).inflate(R.layout.xxx, null);
popwindow.setContentView(popContentsView );

@razerdp
Copy link
Owner

razerdp commented Jun 8, 2023

可以,下个版本看看好不好弄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants