Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork346
Dynamic iOS-like blur of underlying Views for Android
License
Dimezis/BlurView
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Dynamic iOS-like blur for Android Views. Includes a library and a small example project.
BlurView can be used as a regular FrameLayout. It blurs its underlying content and draws it as abackground for its children. The children of the BlurView are not blurred. BlurView updates itsblurred content when changes in the view hierarchy are detected. It honors its positionand size changes, including view animation and property animation.
Important
Version 3.0 info, key changes, migration steps, and what you need to know ishere.
Also, the code path on API 31+ is now completely different from API < 31, so keep in mind to test both.
<eightbitlab.com.blurview.BlurViewandroid:id="@+id/blurView"android:layout_width="match_parent"android:layout_height="wrap_content"app:blurOverlayColor="@color/colorOverlay"><!--Any child View here, TabLayout for example. This View will NOT be blurred--> </eightbitlab.com.blurview.BlurView><!--This is the content to be blurred by the BlurView. It will render normally, and BlurView will use its snapshot for blurring--> <eightbitlab.com.blurview.BlurTargetandroid:id="@+id/target"android:layout_width="match_parent"android:layout_height="match_parent"><!--Your main content here--> </eightbitlab.com.blurview.BlurTarget>
floatradius =20f;ViewdecorView =getWindow().getDecorView();// A view hierarchy you want blur. The BlurTarget can't include the BlurView that targets it.BlurTargettarget =findViewById(R.id.target);// Optional:// Set the drawable to draw in the beginning of each blurred frame.// Can be used in case your layout has a lot of transparent space and your content// gets a low alpha value after blur is applied.DrawablewindowBackground =decorView.getBackground();// Optionally pass a custom BlurAlgorithm and scale factor as additional parameters.// You might want to set a smaller scale factor on API 31+ to have a more precise blur with less flickering.blurView.setupWith(target) .setFrameClearDrawable(windowBackground)// Optional. Useful when your root has a lot of transparent background, which results in semi-transparent blurred content. This will make the background opaque .setBlurRadius(radius)
TextureView can be blurred only on API 31+. Everything else (which is SurfaceView-based) can't be blurred, unfortunately.
Use Jitpackhttps://jitpack.io/#Dimezis/BlurView and release tags as the source of stableartifacts.
implementation'com.github.Dimezis:BlurView:version-3.0.0'
It's possible to set rounded corners without any custom API, the algorithm is the same as with other regular View:
Create a rounded drawable, and set it as a background.
Then set up the clipping, so the BlurView doesn't draw outside the corners
blurView.setOutlineProvider(ViewOutlineProvider.BACKGROUND);blurView.setClipToOutline(true);
Related thread -#37
Because blurring on other threads would introduce 1-2 frames of latency.On API 31+ the blur is done on the system Render Thread.
- BlurView and Haze for Compose are the only libraries that leverage hardware acceleration for View snapshotting and have near zero overhead of snapshotting.
- Supports TextureView blur on API 31+.
- The BlurView never invalidates itself or other Views in the hierarchy and updates only when needed.
- It supports multiple BlurViews on the screen without triggering a draw loop.
- On API < 31 it uses optimized RenderScript Allocations on devices that require certain Allocation sizes, which greatly increases blur performance.
- Supports blurring of Dialogs (and Dialog's background)
Other libs:
- 🛑BlurKit - constantly invalidates itself
- 🛑RealtimeBlurView - constantly invalidates itself
Copyright 2025 Dmytro SaviukLicensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.
About
Dynamic iOS-like blur of underlying Views for Android
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.