Android中的Blur imageView

问题描述 投票:0回答:1

我正在使用在thread中回答的方法,我将依赖项实现到build.gradle中,但是当我粘贴代码时,它向我显示我没有类名Glide的错误。如何解决此问题,以便使ImageView模糊?

我有用于学习的简单代码

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)
      }
 }
android imageview blur
1个回答
0
投票

确保像这样在gradle中指定滑行

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'

应用转换

        Glide.with(this@MainActivity)
           .asBitmap()
           .load(R.drawable.ic_launcher)
           .apply(RequestOptions.bitmapTransform(BlurTransformation(25, 3)))
           .into(imageView)
© www.soinside.com 2019 - 2024. All rights reserved.