A simple library for blur and unblur Views/Images for Android.
- Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
- Add the dependency to app build.gradle
dependencies {
implementation 'com.github.kAvEh--:blur_view:1.0.0'
}
- Insert
BlurView
widget in your layout.
<com.kaveh.blurview.BlurView
android:id="@+id/blurView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="Your Image" />
- Set the BlurRadius of image (Must be Float between 0-25)
findViewById<BlurView>(R.id.blurView).blurRadius = 15F
findViewById<BlurView>(R.id.blurView).blur()
- For unblurring the image just set the radius to zero
findViewById<BlurView>(R.id.blurView).blurRadius = 0F
findViewById<BlurView>(R.id.blurView).blur()
- Just call blur function on ViewGroup
val viewGroup = (findViewById<View>(android.R.id.content) as ViewGroup).getChildAt(0) as ViewGroup
viewGroup.blur(this@BlurActivity, 20F)
- For removing blur effect from ViewGroup
val viewGroup = (findViewById<View>(android.R.id.content) as ViewGroup).getChildAt(0) as ViewGroup
viewGroup.remove()
Android 4.4+ (API 19)
- Kaveh Fazaeli - kaveh.fazaeli@gmail.com
Copyright 2020 kAvEh--
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.