Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
B

BlurDialogFragment

> 编程语言
Open source

Library project to display DialogFragment with a blur effect.

2.1K stars0 likes0 views
WebsiteGitHub

About

Library project to display DialogFragment with a blur effect.

BlurDialogFragment

This project allows to display DialogFragment with a burring effect behind. The blurring part is achieved through FastBlur algorithm thanks to the impressive work of Pavlo Dudka (cf Special Thanks).

  • Sample app
  • Gradle dependency
  • Example
  • [Use RenderScript in Your Project] (#use-renderscript-in-your-project)
  • Simple usage using inheritance
  • Customize your blurring effect
  • Avoiding inheritance
  • Benchmark
  • Known bugs
  • RenderScript or not RenderScript
  • Change logs
  • Contributing
  • Credits
  • License
  • Special Thanks

Sample app

Download the sample app on the Google Play store.

Gradle dependency

Since the library is promoted on maven central, just add a new gradle dependency :

    compile 'fr.tvbarthel.blurdialogfragment:lib:2.2.0'

Don't forget to check the [Use RenderScript in Your Project] (#use-renderscript-in-your-project) if you're planning to use it.

Example

Activity with action bar [blurRadius 4, downScaleFactor 5.0] :

Fullscreen activity [blurRadius 2, downScaleFactor 8.0] :

Use RenderScript in Your Project

Simply add this line to your build.gradle

defaultConfig {
    ...
    renderscriptTargetApi 22
    renderscriptSupportModeEnabled true
    ...
}

Simple usage using inheritance

If you are using android.app.DialogFragment : extends BlurDialogFragment. Play with the blur radius and the down scale factor to obtain the perfect blur.

Don't forget to enable log if you want to keep on eye the performance.

/**
 * Simple fragment with blurring effect behind.
 */
public class SampleDialogFragment extends BlurDialogFragment {

}

If you are using android.support.v4.app.DialogFragment : extends SupportBlurDialogFragment. Play with the blur radius and the down scale factor to obtain the perfect blur.

Don't forget to enable log in order to keep on eye the performance.

/**
 * Simple fragment with blurring effect behind.
 */
public class SampleDialogFragment extends SupportBlurDialogFragment {

}

Customize your blurring effect

…

Default values are set to :

…

Avoiding inheritance

If you want to avoid inheritance, use directly the BlurEngine. Don't forget to link the engine to the lifecycle of your DialogFragment.

…

Benchmark

Benchmark outdated. Please refer to the debug option of the sample in order to compare FastBlur and RenderScript.

We used a Nexus 5 running a 4.4.4 stock rom for this bench.

Down scale factor 8.0 & Blur Radius 8 : Screenshot

Radius : 8
Down Scale Factor : 8.0
Blurred achieved in : 18 ms
Allocation : 4320ko (screen capture) + 270ko (FastBlur)

Down scale factor 6.0 & Blur Radius 12 : Screenshot

Radius : 12
Down Scale Factor : 6.0
Blurred achieved in : 31 ms
Allocation : 4320ko (screen capture) + 360ko (FastBlur)

Down scale factor 4.0 & Blur Radius 20 : Screenshot

Radius : 20
Down Scale Factor : 4.0
Blurred achieved in : 75 ms
Allocation : 4320ko (screen capture) + 540ko (FastBlur)

Known bugs

  • Wrong top offset when using the following line in application Theme :
<item name="android:windowActionBarOverlay">true</item>

RenderScript or not RenderScript

Thanks to amasciul blurring effect can now be achieved using ScriptIntrinsicBlur (v1.1.0).

Find more information on the memory trace and on the execution time.

Change logs

  • 2.2.0 : Fix preDrawListener registration when there was no certitude that onPreDraw will be called thanks to Serkan Modoğlu and Mark Mooibroek reports.
  • 2.1.6 : Fix orientation change as well as retainInstance thanks to IskuhiSargsyan report and tweak FastBlur implementation to avoid the allocation of 3 additional arrays for RGB channels thanks to sh1 feedback.
  • 2.1.5 : Minor fixes thanks to Edward S and Tommy Chan.
  • 2.1.4 : Fix NPE during the blurring process thanks to Anth06ny, jacobtabak and serega2593 reports.
  • 2.1.3 : Remove unused resources thanks to ligol report.
  • 2.1.2 : Rework support of translucent status bar thanks to wangsai-silence report.
  • 2.1.1 : Fix usage without renderscript as VerifyError was fired.
  • 2.1.0 : Support AppCompatActivity and fix several bugs thanks to jacobtabak.
  • 2.0.1 : BlurEngine is back again (restore "avoiding inheritance" usage, thanks to sergiopantoja report).
  • 2.0.0 : Min SDK 9+, don't forget to check the above section "Use RenderScript in Your Project". (thanks to ligol).
  • 1.1.0 : Allow to use RenderScript (thank to amasciul).
  • 1.0.0 : Animate blurring effect, support tablet, tweak nav bar offset and reduce memory allocation.
  • 0.1.2 : Fix bottom offset introduce by the navigation bar on Lollipop.
  • 0.1.1 : Fix top offset when using Toolbar.
  • 0.1.0 : Support appcompat-v7:21.
  • 0.0.9 : Change default blur radius (8) and default down scale factor (4).
  • 0.0.8 : Fix NoClassDefFound.
  • 0.0.7 : Avoid using inheritance through BlurDialogEngine if needed.

Contributing

Contributions are welcome (: You can contribute through GitHub by forking the repository and sending a pull request.

When submitting code, please make every effort to follow existing conventions and style in order to keep the code as readable as possible. Please also make sure your code fit these convention by running gradlew check.

Credits

Credits go to Thomas Barthélémy https://github.com/tbarthel-fr and Vincent Barthélémy https://github.com/vbarthel-fr.

License

Copyright (C) 2014 tvbarthel

Licensed 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.0

Unless required by applicable law or agreed to in writing, software
distributed 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 and
limitations under the License.

Special Thanks to ...

Pavlo Dudka https://github.com/paveldudka/ , for his impressive article on Advanced blurring techniques.

Vincent Brison https://github.com/vincentbrison , for his early day support.

Alexandre Masciulli https://github.com/amasciul , for the integration of RenderScript.

GitHub Issues· 0 open

View all on GitHub

No open issues yet, or sync has not completed.

Highlights

  • •Sample app
  • •Gradle dependency
  • •[Use RenderScript in Your Project] (#use-renderscript-in-your-project)
  • •Simple usage using inheritance
  • •Customize your blurring effect
  • •Avoiding inheritance
  • •Benchmark
  • •Known bugs
  • •RenderScript or not RenderScript
  • •Change logs

> Tags

Java

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言