我正在try 创建一个Appwidget,使用带有.SVG图像支持的Glance Jetpack.

我可以使用以下工具下载位图

ImageRequest.Builder(this)
        .data(url)
        .decoderFactory(SvgDecoder.Factory())

...正如日志(log)的最后一行所示,有一个分配给var coinImage的非空位图.

The problem is, the widget doesn't seem to re-compose after the bitmap's value changes. I'm stuck seeing the circularProgressSpinner. widget screenshot What am I missing/doing wrong? Am I missing something foundational with the composition's state?

我的代码和日志(log)位于: https://gist.github.com/Alvtag/5bd46a2007e6c4f382d431e43aa96e80

如有任何帮助,我们不胜感激!

推荐答案

当前的Glance alpha05不支持重组.

部分重组支持将在下一个版本中出现.您可以使用快照来访问它.

在不重新组合的情况下,您应该遵循此示例 https://github.com/android/user-interface-samples/blob/main/AppWidget/app/src/main/java/com/example/android/appwidget/glance/image/ImageGlanceWidget.kt

有了重组支持,它将得到简化 https://gist.github.com/marcelpinto/6df5e3e6ca42c6a0bf34b9f4b6eb1cff

Android相关问答推荐

垂直居中图标

listOf(listOf(字符串))在lazyArchitect(lazyStream)中合成

使用不同的Google帐户登录

泛型类型lambda函数参数作为函数参数

Android在NavHost中的LazyColumn中编写约束布局:error - replace()在未放置的项目上调用

Jetpack Compose:带芯片的Textfield

从片段导航回来

Android v31 及更低版本中 ImageView 中的圆角

使用 async 向网络发出并行请求并在supervisorScope中处理它们

如何正确创建可拖动的浮动视图?

Jetpack Compose 动画的行为是什么?

未解决的参考:pagerTabIndicatorOffset

如何只允许拖动 BottomSheetScaffold 中 BottomContent 的 SheetPeek 的一部分?

如何在 Jetpack Compose 中的 VisualTransformation 之后将光标保持在文本字段的末尾

Material Design 网站的新设计已启动,但我找不到实现选项卡,该选项卡在哪里?

为什么官方文档用大写字母表示val变量?

为什么我在 Jetpack Compose 中被警告可选修饰符参数应该具有默认值修饰符?

单击登录按钮后从应用程序中退出

Android TTS 在屏幕关闭一段时间后停止朗读

如何增加 BottomSheetDialog 的高度以跟随垂直平移