小编F.M*_*sir的帖子

带动画的 LazyColumn 内的 SwipeToDismiss

I am trying to achieve something like this but with Jetpack Compose. In other words swipe to delete like we could do in RecyclerView with ItemTouchHelper and class DiffCallBack : DiffUtil.ItemCallback<RvModel>() where we could see enter - exit animations and then the list moving gracefully up or down where the item has been inserted or removed.

This is what I have tried:

LazyColumn(state = listState) {
    items(products, {listItem:InventoryEntity -> listItem.inventoryId}) { item ->
        var unread by remember { mutableStateOf(false) } …
Run Code Online (Sandbox Code Playgroud)

android kotlin android-jetpack-compose

4
推荐指数
1
解决办法
5371
查看次数

观察 Android 可组合项当前时间的最“轻量级”方式是什么?

lightweight从可组合项的 viewModel 观察当前时间的最有效方法是什么。

在我的可组合项看来,我希望看到当前时间的格式为HH:mm并始终根据当前时间进行更新。

android kotlin kotlin-coroutines android-jetpack-compose

3
推荐指数
1
解决办法
829
查看次数

如何在 jetpack compose 中使用来自 URI 的 Coil 加载图像

我正在使用最新版本的线圈:

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
    )

}
Run Code Online (Sandbox Code Playgroud)

这工作正常,当我尝试从如下所示的 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
    )
}
Run Code Online (Sandbox Code Playgroud)

有关如何在labelary上创建标签 .png 的更多信息

android android-jetpack-compose coil

2
推荐指数
1
解决办法
6903
查看次数