gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 14:35:15 24 4
gpt4 key购买 nike

我用过GlideCoil通过 Jetpack Compose 通过 URL 加载图像。
但是,图像只有黑色。我怎样才能解决这个问题?
我的 ComposeCoil版本是最新版本。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
)
}
结果屏幕:(橙色圆圈为 Icon)
problem screen

最佳答案

摆脱图标上的色调。

Icon(
painter = rememberImagePainter(imageURL),
contentDescription = null,
modifier = Modifier.size(42.dp),
tint = Color.Unspecified
)

关于android - 从 URL 加载的 Jetpack Compose 图像始终为黑色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67444081/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com