网上大部分解释是RecycleView的条目动画导致的,其实是不准确的.
第一步:
GlideApp.with(context) .asBitmap() .load(url) .into(object : SimpleTarget<Bitmap>() { override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) { //TODO 核心方法 自己将加载完成的资源塞给 imageView //TODO 使用Glide的into方法会出现Glide默认动画,且 .dontAnimate()无效 imageView.setImageBitmap(resource) } })
如果遇到到圆角或者圆形图片则直接写一个继承ImageView的自定义控件,使用 canvas?.clipPath(path)裁剪, 不只是圆角,通过path添加,任意形状都可以裁剪出来. 第二步: open class ImageViewWithRadius : AppCompatImageView { private var radius: Float = 0.0f constructor(context: Context) : this(context, null) constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0) constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super( context, attrs, defStyleAtt