我关心的是如何使用 android:scaleType="fitXY"
将图像适配到使用 Glide 的图像中。
我的ImageView
是
<ImageView
android:id="@+id/img_pager"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:scaleType="fitXY" />
像这样使用 Glide 加载图像
Glide.with(context).load(url).placeholder(R.drawable.default_image).into(img);
但图像不适合 ImageView
它在图像两侧显示空间,如屏幕所示我需要它 fitXY
最佳答案
您可以使用 centerCrop()
或 fitCenter()
方法:
Glide.with(context)
.load(url)
.centerCrop()
.placeholder(R.drawable.default_image)
.into(img)
或
Glide.with(context)
.load(url)
.fitCenter()
.placeholder(R.drawable.default_image)
.into(img)
您还可以在以下网址找到更多信息:https://futurestud.io/tutorials/glide-image-resizing-scaling
关于android - 如何使用 Glide 将 Image 放入 ImageView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34022552/