【发布时间】:2019-03-29 07:53:05
【问题描述】:
我在我的项目中使用 glide 在回收站视图中显示图像。图像将从服务器下载,直到我显示分辨率非常低的模糊图像。模糊后的图像是 base 64 编码的图像,将转换为 byteArray 以显示在 glide 中。
我的问题是每次调用notifydatasetchanged() 函数时,base 64 解码图像都会闪烁。如何避免这种奇怪的行为?
我在同一个回收站视图中将本地存储中的图像作为文件加载,但在调用notifydatasetchanged() 时没有闪烁问题。
仅针对模糊图像(base 64 解码位图)出现闪烁问题
我使用的是 glide 版本:4.8.0
//converting string to byteArray
byte[] blurImg = getBlurImageBitmap(fileDataTable.get("blurimg") as String)
//function which converts the image string to byteArray
fun getBlurImageBitmap(blurImageString : String) : ByteArray {
val decodedBytes = Base64.decode(blurImageString, android.util.Base64.DEFAULT)
return decodedBytes
}
//loading the byteArray into glide
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
Glide.with(imageMessage.context)
.load(chatMessage.fileData.blurImg)
.transition(DrawableTransitionOptions.withCrossFade(1))
.into(imageMessage)
}
我想避免base 64图像在滑翔中闪烁。
【问题讨论】:
-
试过了,但没有解决我的问题。我已经用过 setStableIds(true)
-
针对老版本glide给出的解决方案。即使当我更改为旧版本时仍然会出现问题
标签: android android-recyclerview base64 android-glide