滑动缩放问题
Glide scaling issues
我在缩放从 url 加载的图像时遇到一些问题。
它们每两次的缩放比例都不同。所以起初它们被正确加载。如果我刷新视图。图像按比例缩小。然后,如果我再刷新一次。视图再次正确缩放。
还有其他人对 glide 有类似的问题吗?
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"/>
已找到解决此问题的方法。感谢以下urlhttps://github.com/bumptech/glide/issues/1591
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)
}
所以换句话说,我只是调用了 imageview.layout(0,0,0,0)
来重置图像视图。这是在 override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int)
中完成的
我在缩放从 url 加载的图像时遇到一些问题。
它们每两次的缩放比例都不同。所以起初它们被正确加载。如果我刷新视图。图像按比例缩小。然后,如果我再刷新一次。视图再次正确缩放。
还有其他人对 glide 有类似的问题吗?
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"/>
已找到解决此问题的方法。感谢以下urlhttps://github.com/bumptech/glide/issues/1591
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)
}
所以换句话说,我只是调用了 imageview.layout(0,0,0,0)
来重置图像视图。这是在 override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int)