Hi! Does anyone know if it is possible to create a...
# compose-android
s
Hi! Does anyone know if it is possible to create a
Modifier
extension to add blur effect that is compatible with all Android versions?
Modifier.blur()
is compatible with Android 12 and above and I was trying to encapsulate all the compatible logic in one extension function. I have tried to use graphics layer and adding a
BlurEffect
to
renderEffect
but with no luck in my Android 10. Any ideas? This is the code I have tried at this moment.
Copy code
@Composable 
fun Modifier.compatBlur ( radius: Float
: Modifier = 
if(Build.VERSION.SDK_INT <= Build. VERSION_CODES.S)
 graphicslayer {
   if (radius > 0f)
   renderEffect = BlurEffect(radius,radius)
}
else this.blur(radius.dp)
j
s
Does haze work for older versions? https://kotlinlang.slack.com/archives/CJLTWPH7S/p1651845634528419 Read more here 😄
❤️ 2
j
It falls back to scrim, I think
Better than nothing
👍 1