使用Coil in compose进行预加载,然后显示图像

发布于 2025-02-11 12:25:56 字数 586 浏览 1 评论 0原文

我一直在圈子四处走动,试图弄清楚如何在组合中使用线圈。我想预加载图像,以便我的UI中不会有任何滞后。我读到线圈有一个缓存。 这个答案似乎意味着我可以使用分配的内存缓存键创建一个ImageRequest,然后在异步组合中使用该请求。我似乎找不到涵盖Coil2.0的文档。我认为我不需要使用ImageLoader或RemallPainter()或ImageViews作为目标……

此时,我很困惑,以至于我只是不知道该去哪里。有另一个堆栈溢出问题这似乎是在主题上,但是我可以理解答案。它显示了如何预加载,但没有最终显示图像。也许是这样,我只是看不到它。

任何人都可以将我指向正确的方向,以获得COOIL 2.0,预加载图像,这些图像在没有UI滞后的某个点显示。

I've been going around in circles trying to figure out how to use Coil within Compose. I want to preload the images so there won't be any lag in my UI. I read that COIL has a cache. This answer seems to imply that I can create an ImageRequest with an assigned memory cache key, and then use that request in an AsyncImage composable. I can't seem to find documentation that covers COIL2.0 . I don't think I need to use ImageLoader or rememberPainter() or ImageViews as targets......

At this point I'm so confused that I just don't know where to turn. There is another stack overflow question that seems on topic, but I can't understand the answer. It shows how to preload, but not how to ultimately display the images. Or maybe it does and I'm just not seeing it.

Can anyone point me in the right direction for Cooil 2.0, preloading images that are at some later point displayed without UI lag.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

原野 2025-02-18 12:25:56

就像以前的话题回答
为了显示图像,您可以使用 asyncimage

Just like previous topic answered
In order to display the image you can use AsyncImage

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文