在构建服务器收到的通知时,我正在尝试裁剪图像。此时此刻,我只有图片的网址。
这是我尝试过的:
Coil.load(context, remoteMessage.getImageUrl()) {
target { image ->
transformations(CircleCropTransformation())
val person = Person.Builder()
.setName(remoteMessage.getTitle())
.setIcon(IconCompat.createWithBitmap(image.toBitmap()))
.build()
...它加载图像,但不进行裁剪。
发布于 2020-01-15 02:04:02
哦,我刚刚发现了问题所在。CircleCropTransformation()应在目标块外部应用,例如:
Coil.load(context, remoteMessage.getImageUrl()) {
transformations(CircleCropTransformation())
target { image ->
val person = Person.Builder()
.setName(remoteMessage.getTitle())
.setIcon(IconCompat.createWithBitmap(image.toBitmap()))
.build()奇怪的是:它确实适用于circleCropTransformation,但在使用RoundedCornersTransformation时似乎不起作用
https://stackoverflow.com/questions/59739210
复制相似问题