Dynamic blur imageview in Android

Sometime we want dynamically blur ImageView like fuzzy effect ie, Yahoo weather app. Now, more and more App inside the use of a fuzzy effect, I especially like the Yahoo weather interface, when the background picture will follow the move, the most important thing is the background image will be based on the distance between the fingers to move to different degrees Fuzzy, feeling very surprised.

Do you know aboutAndroid O features and API you should know

After all, we all know that in the Android platform for fuzzy rendering is a considerable consumption of CPU is also quite time-consuming operation, once handled well, Caton is inevitable. Although I do not know how Yahoo weather is doing this effect, but simply imitate the words, or can do it.

Have you check thisWhat’s new features in Android Studio 2.3

Dynamically blur ImageView in Android
Dynamically blur ImageView in Android

How to implement dynamically blur ImageView in your project ?

Gradle

compile 'com.qiushui:blurredview:0.8.1'

 Enable RenderScript support mode:

defaultConfig {
renderscriptTargetApi 19
renderscriptSupportModeEnabled true
}

How to use

<com.qiushui.blurredview.BlurredView
app:src="@drawable/dayu"
app:move="true"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
  • You can use app:src=”@drawable/XXX” in layout to set the image to be blurred.Or you may use mBlurredView.setBlurredImg(); in your java code to specify the image to be blurred.
  • You can use mBlurredView.setBlurredLevel(int alpha)to determine the level of blur. The value of alpha is between 0 and 100.
  • You’ll use mBlurredView.setBlurredTop(int topDistance)to make blurred image move when app:move=”true” is special. The value of topDistance is between 0 to 100.

Notice

  • Make sure your build tools version is above 23.0.3 .
  • This library is only work for .png image.
  • Usually, you need add the following code in defaultConfig :
    ndk {
    abiFilters "armeabi","armeabi-v7a", "x86", "mips"
    }

How is it? Is it very simple to look like? Only need to call the fuzzy processing methods, and SeekBar sliding monitor inside the call to the original image of the setAlpha()method to achieve dynamic fuzzy effect.

If you’ve any query then comment below.

By Tell Me How

It is a technology blog and admin has excellent experience in programming from 5+ year. You can contact us at ceo.tellmehow@gmail.com

Share your thoughts

Leave a Reply

Loading Facebook Comments ...
Loading Disqus Comments ...