问题描述
我对android中图像的处理有很多疑惑,希望看看你能不能解决.
I have a lot of doubts about the treatment of the images in android, and I was hoping to see if you could solve them.
此时我有一个高度为 320 dp 的图像和 match_parent 宽度,大约是屏幕的 60%.这张使用 Glide 加载的图像,以及我个人拥有的 1080 中的一些图像.
At this point I have an image that occupies 320 dp high, and match_parent width, which is around 60% of the screen. This image of the load with Glide, of some images in 1080 that I have personally.
我尝试制作 centroCrop 和 fitXY,但总是使图像变形.我知道的第一种类型会剪切图像,但第二种适合大小,但它确实会使图像变高或变宽.
I tried to make centroCrop and fitXY, but always deform the images. The first type I know cuts the image, but the second one fits a size, but it does deform the image high or wide.
有什么方法可以用 Glide 插入它并按原样查看吗?我在 ImageView 和 Glide 上需要触摸哪些属性?
Is there any way, to insert it with Glide and see it as it is? What properties have I to touch on ImageView and which of Glide?
<ImageView
android:id="@+id/img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:nestedScrollingEnabled="false"
app:layout_collapseMode="parallax"
android:scaleType="fitXY"
app:layout_scrollFlags="scroll|enterAlways" />
推荐答案
Override
必须通过 RequestOptions
在最新版本的 Glide 4.x 中访问代码>.可以通过
apply()
Override
must be accessed via RequestOptions
in the most recent version of Glide 4.x
. You can add RequestOptions
through apply()
Glide
.with(context)
.load(path)
.apply(new RequestOptions().override(600, 200))
.into(imageViewResizeCenterCrop);
这篇关于在 Android ImageView 中使用 Glide 调整图像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!