glide scaletype 无效,在ImageView Android中使用Glide调整图像大小

博主求助如何在Android中使用Glide正确加载高分辨率图片,尝试了centerCrop和fitXY但导致变形。寻求不裁切且保持原始比例的插入方法及ImageView设置建议。Elletlar评论提供了解决方案:通过RequestOptions调整图片尺寸。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.

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.

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.

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?

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" />

Thanks in advance.

解决方案

Elletlar comment:

Override must be accessed via RequestOptions in the most recent version of Glide.

Glide

.with(context)

.load(path)

.apply(new RequestOptions().override(600, 200))

.into(imageViewResizeCenterCrop);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值