Android 滑动缩放问题
当涉及到从url加载的图像的缩放时,我遇到了一些问题 它们每秒钟的规模都不同。因此,首先它们被正确加载。如果我刷新视图。图像被缩小。如果我下次再刷新。视图再次正确缩放 还有谁对glide有过类似的问题Android 滑动缩放问题,android,android-glide,Android,Android Glide,当涉及到从url加载的图像的缩放时,我遇到了一些问题 它们每秒钟的规模都不同。因此,首先它们被正确加载。如果我刷新视图。图像被缩小。如果我下次再刷新。视图再次正确缩放 还有谁对glide有过类似的问题 fun ImageView.loadUrl(key: String?, gameName: String?, width: Int?, height: Int?) { val storage = FirebaseStorage.getInstance() GlideApp.with
fun ImageView.loadUrl(key: String?, gameName: String?, width: Int?, height: Int?) {
val storage = FirebaseStorage.getInstance()
GlideApp.with(context)
.load(storage.getGameStorageReference(gameName!!, key!!))
.into(this)
}
这就是图像加载的方式。忽略函数中的额外属性。它们将在以后使用
正确的方法
走错了路
XML
<ImageView
android:id="@+id/iv_feed_image_content_image"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:scaleType="fitCenter"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_feed_image_input"
tools:src="@tools:sample/avatars"/>
找到了此问题的解决方案。感谢下面的url 换句话说,我只是调用了
imageview.layout(0,0,0,0)
来重置imageview。这是在override-on-bindViewHolder(holder:RecyclerView.ViewHolder,position:Int)中完成的。
fun ImageView.loadUrl(key: String?, gameName: String?, width: Int?, height: Int?) {
layout(0,0,0,0)
val storage = FirebaseStorage.getInstance()
GlideApp.with(context)
.load(storage.getGameStorageReference(gameName!!, key!!))
.into(this)
}