首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在创建通知时,coil可以转换图像吗?

在创建通知时,coil可以转换图像吗?
EN

Stack Overflow用户
提问于 2020-01-15 01:48:23
回答 1查看 200关注 0票数 0

在构建服务器收到的通知时,我正在尝试裁剪图像。此时此刻,我只有图片的网址。

这是我尝试过的:

代码语言:javascript
复制
Coil.load(context, remoteMessage.getImageUrl()) {
        target { image ->
            transformations(CircleCropTransformation())
            val person = Person.Builder()
                .setName(remoteMessage.getTitle())
                .setIcon(IconCompat.createWithBitmap(image.toBitmap()))
                .build()
         ...

它加载图像,但不进行裁剪。

EN

回答 1

Stack Overflow用户

发布于 2020-01-15 02:04:02

哦,我刚刚发现了问题所在。CircleCropTransformation()应在目标块外部应用,例如:

代码语言:javascript
复制
Coil.load(context, remoteMessage.getImageUrl()) {
    transformations(CircleCropTransformation())
    target { image ->
        val person = Person.Builder()
            .setName(remoteMessage.getTitle())
            .setIcon(IconCompat.createWithBitmap(image.toBitmap()))
            .build()

奇怪的是:它确实适用于circleCropTransformation,但在使用RoundedCornersTransformation时似乎不起作用

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59739210

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档