如何使用滑行下载图像的调整大小版本 [英] How to download a resized version of an image with glide

查看:53
本文介绍了如何使用滑行下载图像的调整大小版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包括图像网格的回收站视图.这是我要加载所述图像的代码.

I have a recycler view which consists of a grid of images. This is the code I sue to load said images.

    @Override
    public void onBindViewHolder(ShowHolder holder, int position) {
        Item current = mItems.get(position);

        String imageUrl = current .getUrl();
        Glide.with(getActivity()).load(imageUrl).into(holder.mImageView);
    }

问题在于图像的大小可以变化,因此Glide需要花费更多的时间来加载某些图像而不是其他图像.相反,我希望以相同的分辨率下载每张图像,从而减少下载时间和数据使用量.

The problem is that the images can be of varying sizes, so Glide takes more time to load some images rather than others. Instead I want every image to be downloaded in the same resolution, thus reducing downlaod time and data usage.

我该怎么做?谢谢.

推荐答案

替换为:

Glide.with(getActivity()).load(imageUrl)

Glide.with(getActivity()).load(imageUrl)

.override(600,200)//将图像调整为这些尺寸(以像素为单位)

.override(600, 200) // resizes the image to these dimensions (in pixel)

.centerCrop()//这种裁剪技术可以缩放图像

.centerCrop() // this cropping technique scales the image

.into(holder.mImageView);

.into(holder.mImageView);

这篇关于如何使用滑行下载图像的调整大小版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆