Android introduced RenderEffect in the latest Android S. How do i use this in my project?
CodePudding user response:
RenderEffect API only exits in API level 31 and succeeds. For earlier version compatibility, you have to work with Bitmap Here is the very instructive group of blog post links RenderEffect and Series of Image blurring; I believe it will be effective for you.
CodePudding user response:
Works only on Android 12 as of now so is not a universal solution yet
To blur a view
1 Set your target SDK and compile SDK to Android S in build.gradle
2.Use Render Effect
3.set blur as follows
your_view.setRenderEffect(
RenderEffect.createBlurEffect(
30f, //radius X
30f, //Radius Y
Shader.TileMode.[X]// X=CLAMP,DECAL,MIRROR,REPEAT
)
- The 4 types of blend mode are
CLAMP- Replicate the edge color if the shader draws outside of its original bounds
DECAL- Render the shader's image pixels only within its original bounds
MIRROR- Repeat the shader's image horizontally and vertically, alternating mirror images so that adjacent images always seam.
REPEAT - Repeat the shader's image horizontally and vertically.