'Android Jetpack Compose (Composable) Disable Hardware Acceleration for particular composable

I have a composable, that is using NativeCanvas together with BlurMaskFilter for applying some custom blur effect. This is working fine for device with with API > 23, and the problem is caused by hardware acceleration for older devices.

Here you can see the blur is working on API 30 (left) and not so much on API 22 (right).

enter image description here

I know that I can disable it manually for the whole application or activity from the manifest file using android:hardwareAccelerated="false".

For Views we could disable it for particular views rather than the whole activity using view.setLayerType(View.LAYER_TYPE_SOFTWARE, null)

Is there a way we could disable the hardware acceleration for particular Composable and not for the whole application/activity?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source