在Android中滑行多重转换 [英] Glide Multiple transformations in Android

查看:133
本文介绍了在Android中滑行多重转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用Glide在我的应用程序中加载图像.我有一个自定义转换,用于在 ImageView 中加载图像时使用.
问题是我想应用自定义转换& centerCrop 都在获取的图像上.但是Glide仅使用我的自定义转换,并使用 fitXY ImageView 中显示图像.
这是我的代码:

I've been using Glide to load images in my app. I've a custom transformation which I'm using while loading an image in ImageView.
The problem is I want to apply my custom transformation & centerCrop both on the image fetched. But Glide is using only my custom transformation and displaying the image in ImageView with fitXY.
Here is my code:

Glide.with(context)
    .load(uri)
    .placeholder(R.drawable.image_id)
    .transform(new CustomTransformation(context))
    .centerCrop()
    .into(imageView);

如何获得理想的结果?任何帮助将不胜感激.

How do I achieve the desired result? Any help would be much appreciated.

推荐答案

在Glide v4.6.1中,我发现 MultiTransformation 类使此操作变得容易:

In Glide v4.6.1, I found that the MultiTransformation class makes this easy:

MultiTransformation<Bitmap> multiTransformation = new MultiTransformation<>(new CustomTransformation(), new CircleCrop());

Glide.with(DemoActivity.this).load(file)
                .apply(RequestOptions.bitmapTransform(multiTransformation))
                .into(mPreviewImageView);

这篇关于在Android中滑行多重转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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