0

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)
                )
            }
        }

在此处输入图像描述

预计:

在此处输入图像描述

4

1 回答 1

2

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

于 2021-07-10T12:37:50.293 回答