Sergio Moral
03/14/2024, 12:35 PMModifier
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.
@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)
jw
03/14/2024, 12:37 PMStylianos Gakis
03/14/2024, 12:40 PMjw
03/14/2024, 12:42 PMjw
03/14/2024, 12:42 PM