Reputation: 27
I am using the method answered in this thread I implemented the dependencies into build.gradle
but when I paste the code it shows me errors that I don't have class name Glide
. How do I work around this so I can make my ImageView
blur?
I have simple code for learning purposes
imageView4.setOnClickListener {
if (!haveImage) {
Toast.makeText(this, "Image not imported yet!", Toast.LENGTH_LONG).show()
} else {
val imgUri = Uri.parse("android.resource://com.example.myapplication/" + R.drawable.ic_launcher)
imageView4.setImageURI(imgUri)
}
}
Upvotes: 1
Views: 524
Reputation: 30765
With the new Android API Level 31 (Android 12) you can use method android.view.View#setRenderEffect()
to apply blur effect to a view:
imageView.setRenderEffect(
RenderEffect.createBlurEffect(
20.0f, 20.0f, Shader.TileMode.CLAMP
)
)
Upvotes: 0
Reputation: 1737
Make sure to specify Glide in gradle
like this
implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation 'jp.wasabeef:glide-transformations:4.1.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
Apply the transformation
Glide.with(this@MainActivity)
.asBitmap()
.load(R.drawable.ic_launcher)
.apply(RequestOptions.bitmapTransform(BlurTransformation(25, 3)))
.into(imageView)
Upvotes: 1