Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blur in Jetpack Compose

How can I blur a background or create a Blur Overlay in Jetpack Compose? There is no documentation or resources whatsoever addressing this topic. Simply said: I'm looking to implement something like this natively in Jetpack Compose

like image 474
Yannick Avatar asked Feb 01 '21 19:02

Yannick


People also ask

How do I blur my Android screen?

Or, just pre-render your blurred image if you're not animating the blur. There are two way to achieve. 1) You can use FrameLayout to which you can set blur background. 2) You can use latest Blur library which i have !

Can you blur in CSS?

blur() The blur() CSS function applies a Gaussian blur to the input image. Its result is a <filter-function> .

How do you change the background on compose?

To set a specific background color for a Column in Android Compose, use Modifier. background() for the Column modifier parameter. Required Color object can be passed to background() function for color parameter.

How to create an imagepainter using jetpack compose?

To add support for Jetpack Compose, import the extension library: Then use the rememberImagePainter function to create… 2. Adding Permissions 3. Downloading the image We can use the rememberImagePainter function to create an ImagePainter that can be drawn by the Image composable:

What is Jetpack compose for Android development?

Jetpack Compose is one of the recent attempts by Google to make it easy for Android developers to build UI. “Jetpack Compose is a modern toolkit for building native Android UI. Jetpack Compose simplifies and accelerates UI development on Android with less code, powerful tools, and intuitive Kotlin APIs.” — Android Developers

What is backdrop component in jetpack?

Backdrop component is composed of 2 surfaces: back layer and front layer. Purpose of back layer is to display context. Part of the it is appBar. Purpose of front layer is to show content based of context from back layer. Backdrop is implemented in Jetpack Compose as BackdropScaffold composable.

Does jetpack compose support persistent or modal bottom sheets?

Jetpack Compose out of the box supports both persistent and modal bottom sheets. Any other draggable bottom sheets also have their own scaffolds: BottomSheetScaffold and ModalBottomSheetLayout. BottomSheetScaffold is a simple composable function used to display the persistent bottom sheet. Have a look at the composable:


2 Answers

This is a feature that has been requested (implemented in Compose 1.1.0-alpha03 for android 12 and above only) and which you might want to star.
The idea would be to create a blur modifier that would look like this:

Modifier.blur(radius = 16.dp, dynamic = true)
like image 157
Code Poet Avatar answered Sep 18 '22 14:09

Code Poet


In Jetpack Compose:1.1.0-alpha03, you can use:

Modifier.blur(30.dp)

but is only supported on Android 12 and above. Attempts to use this Modifier on older Android versions will be ignored.

Reference: Modifier.blur

like image 21
Orlando Novas Rodriguez Avatar answered Sep 16 '22 14:09

Orlando Novas Rodriguez