如何使用线圈为图像自定义

问题描述

我在我的项目中使用了 coil:0.10.0 但它不符合预期,我想更改图像的背景

val painter = rememberCoilPainter(
                fadeIn = true,request = ImageRequest.Builder(LocalContext.current)
                    .data(entry.imageUrl)
                    .target {
                        viewmodel.calcDominantColor(it) { color ->
                            dominantColor = color
                        }
                    }
                    .build()
            )
            Column {   
                Image(
                  painter = painter,contentDescription = entry.pokemonName,modifier = Modifier
                             .size(120.dp)
                             .align(CenterHorizontally)
                )
            }
        }

enter image description here

预期:

enter image description here

解决方法

试试Modifier.background(brush = verticalGradient(listOf(dominantColor,Color.White)))