相关疑难解决方法(0)

如何用Glide库舍入图像?

所以,有人知道如何使用Glide显示带圆角的图像吗?我正在使用Glide加载图像,但我不知道如何将舍入的参数传递给此库.

我需要显示图像如下例子:

在此输入图像描述

android android-glide

174
推荐指数
11
解决办法
13万
查看次数

Android glide:裁剪 - 从图像底部剪掉 X 像素

我需要从图像底部切掉 20px 并缓存它,这样设备就不必每次用户再次看到图像时都一遍又一遍地裁剪它,否则会对电池等造成不良影响,对吗?

这是我到目前为止所拥有的:

        Glide
            .with(context)
            .load(imgUrl)
            .into(holder.image)



fun cropOffLogo(originalBitmap: Bitmap) : Bitmap {

    return Bitmap.createBitmap(
        originalBitmap,
        0,
        0,
        originalBitmap.width,
        originalBitmap.height - 20
    )
}
Run Code Online (Sandbox Code Playgroud)

我该如何使用cropOffLogowith glide

编辑:

我尝试使用https://github.com/bumptech/glide/wiki/Transformations#custom-transformations

private static class CutOffLogo extends BitmapTransformation {

    public CutOffLogo(Context context) {
        super(context);
    }

    @Override
    protected Bitmap transform(BitmapPool pool, Bitmap toTransform,
                               int outWidth, int outHeight) {

        Bitmap myTransformedBitmap = Bitmap.createBitmap(
                toTransform,
                10,
                10,
                toTransform.getWidth(),
                toTransform.getHeight() - 20);

        return myTransformedBitmap;
    }
}
Run Code Online (Sandbox Code Playgroud)

并得到这些错误:

Modifier 'private' not allowed here

Modifier …
Run Code Online (Sandbox Code Playgroud)

android crop android-glide

7
推荐指数
1
解决办法
2337
查看次数

在Android中滑行多重转换

我一直在使用Glide在我的应用程序中加载图像。我有一个自定义转换,正在将图像加载到中时使用ImageView
问题是我想对centerCrop提取的图像应用我的自定义转换和两者。但滑翔仅使用我的自定义转换和显示图像ImageViewfitXY
这是我的代码:

Glide.with(context)
    .load(uri)
    .placeholder(R.drawable.image_id)
    .transform(new CustomTransformation(context))
    .centerCrop()
    .into(imageView);
Run Code Online (Sandbox Code Playgroud)

如何获得理想的结果?任何帮助将非常感激。

android android-glide

6
推荐指数
2
解决办法
3657
查看次数

标签 统计

android ×3

android-glide ×3

crop ×1