我正在使用最新版本的线圈:
implementation("io.coil-kt:coil-compose:2.0.0-rc01")
我想将条形码标签图像加载到我的 Jetpack Compose 文件中,例如:
Box(modifier = Modifier.background(Color.DarkGray).fillMaxSize()) {
AsyncImage(
model = ImageRequest.Builder(LocalContext.current)
.data("https://www.researchgate.net/profile/Adnan-Ghaffar/publication/313103370/figure/fig3/AS:456489858015234@1485847071322/An-example-of-barcode.png")
.crossfade(true)
.build(),
contentDescription = "barcode image",
contentScale = ContentScale.Crop,
modifier = Modifier
)
}
这很好用,当我尝试从如下 URI 加载图像时出现问题:
http://api.labelary.com/v1/printers/8dpmm/labels/4x6/0/^xa^cfa,50^fo100,100^fdHello World^fs^xz
但它不起作用,例如我试过的代码:
Box(modifier = Modifier.background(Color.DarkGray).fillMaxSize()) {
AsyncImage(
model = ImageRequest.Builder(LocalContext.current)
.data("http://api.labelary.com/v1/printers/8dpmm/labels/4x6/0/^xa^cfa,50^fo100,100^fdHello World^fs^xz")
.crossfade(true)
.build(),
contentDescription = "barcode image",
contentScale = ContentScale.Crop,
modifier = Modifier
)
}
有关如何在labelary上创建标签 .png 的更多信息