我需要使用 Coil 通过 url 在我的应用程序中显示图像,但该图像未加载。我遵循官方文档https://coil-kt.github.io/coil/compose/。
implementation "io.coil-kt:coil-compose:1.3.1"
Run Code Online (Sandbox Code Playgroud)
implementation "io.coil-kt:coil-compose:1.3.1"
Run Code Online (Sandbox Code Playgroud)
更新
UserModel 的一个例子
UserModel(
name = "John Doe",
profilePicture = "https://randomuser.me/api/portraits/men/32.jpg",
online = true
)
Run Code Online (Sandbox Code Playgroud) 我想隐藏navigationIcon,但是当我通过null
或Unit
图标空间仍然可见时,如下图所示。
@Composable
fun DefaultScaffold(
title: String? = null,
icon: ImageVector? = null,
content: @Composable() () -> Unit
) {
Scaffold(
topBar = {
TopAppBar(
title = {
if (title != null) {
Text(text = "My Title")
}
},
navigationIcon = {
if (icon != null) {
IconButton(
onClick = {}
) {
Icon(imageVector = Icons.Filled.Close, contentDescription = null)
}
} else Unit
}
)
}
) {
content()
}
}
Run Code Online (Sandbox Code Playgroud) android android-jetpack android-jetpack-compose android-compose-appbar