Jetpack Compose 从 URL 加载的图像始终为黑色

Ji *_*bin 10 android kotlin android-jetpack-compose

我已经使用GlideCoil通过 Jetpack Compose 通过 URL 加载图像。
然而,图像只有黑色。我怎样才能解决这个问题?

我的Compose版本Coil是最新版本。

kakaoProfile.value!!.profileImageUrl!!: https: //k.kakaocdn.net/dn/IOMxT/btqYvUIVMAL/VZCdMjf01kxnkFFZFNDJ81/img_640x640.jpg

这是我的代码:

Column(
    modifier = Modifier.fillMaxSize(),
    horizontalAlignment = Alignment.End,
    verticalArrangement = Arrangement.Center
{
    if (kakaoProfile.value == null) {
        Icon(
            imageVector = Icons.Outlined.AccountCircle,
            contentDescription = null,
            modifier = Modifier.size(100.dp),
            tint = colors.primary
        ) 
    } else {
        Icon(
            painter = rememberCoilPainter(kakaoProfile.value!!.profileImageUrl!!),
            contentDescription = null,
            modifier = Modifier.size(100.dp)
        )
    }
}
.
.
.
Button(
    modifier = Modifier.padding(start = 8.dp),
    shape = RoundedCornerShape(15.dp),
    colors = ButtonDefaults.buttonColors(backgroundColor = Color(0xFF393939)),
    onClick = {
        if (kakaoProfile.value == null) {
            UserApiClient.instance.loginWithKakaoTalk(context) { token, error ->
                if (error != null) {
                    Log.e("TAG", "Login Fail", error)
                } else if (token != null) {
                    UserApiClient.instance.me { user, _ ->
                        kakaoProfile.value = user?.kakaoAccount?.profile
                    }
                }
            }
        } else {
            UserApiClient.instance.logout {
                kakaoProfile.value = null
            }
        }
    }
) {
    Text(
        text = if (kakaoProfile.value == null) "login" else "logout",
        fontSize = 18.sp,
        color = Color.White
    )
}
Run Code Online (Sandbox Code Playgroud)

结果屏幕:(橙色圆圈是Icon
问题屏幕

Dan*_*ugh 41

去掉图标上的色调。

Icon(
  painter = rememberImagePainter(imageURL),
  contentDescription = null,
  modifier = Modifier.size(42.dp),
  tint = Color.Unspecified
)
Run Code Online (Sandbox Code Playgroud)

  • 为什么默认有色调需要撤消? (4认同)

lig*_*igi 20

我遇到了同样的问题,我需要将图标更改为图像 - 似乎图标在撰写中是黑白(形状)的。