远程撰写

  
Remote Compose 是一个用于为远程 surface 创建界面的框架
最近更新时间 稳定版 候选版 Beta 版 Alpha 版
2026 年 9 月 23 日 - - - 1.0.0-alpha20

声明依赖项

如需添加 compose-remote 的依赖项,您必须将 Google Maven 制品库添加到项目中。如需了解详情,请参阅 Google 的 Maven 制品库。

在应用或模块的 build.gradle 文件中添加所需工件的依赖项:

Groovy

dependencies {
    implementation "androidx.compose.remote:remote-core:1.0.0-alpha20"

    // Use to create Remote Compose documents
    implementation "androidx.compose.remote:remote-creation:1.0.0-alpha20"
    implementation "androidx.compose.remote:remote-creation-core:1.0.0-alpha20"
    implementation "androidx.compose.remote:remote-creation-android:1.0.0-alpha20"
    implementation "androidx.compose.remote:remote-creation-jvm:1.0.0-alpha20"
    implementation "androidx.compose.remote:remote-creation-compose:1.0.0-alpha20"

    // Use to render a Remote Compose document
    implementation "androidx.compose.remote:remote-player-core:1.0.0-alpha20"
    implementation "androidx.compose.remote:remote-player-view:1.0.0-alpha20"

    implementation "androidx.compose.remote:remote-tooling-preview:1.0.0-alpha20"
}

Kotlin

dependencies {
    implementation("androidx.compose.remote:remote-core:1.0.0-alpha20")

    // Use to create Remote Compose documents
    implementation("androidx.compose.remote:remote-creation:1.0.0-alpha20")
    implementation("androidx.compose.remote:remote-creation-core:1.0.0-alpha20")
    implementation("androidx.compose.remote:remote-creation-android:1.0.0-alpha20")
    implementation("androidx.compose.remote:remote-creation-jvm:1.0.0-alpha20")
    implementation("androidx.compose.remote:remote-creation-compose:1.0.0-alpha20")

    // Use to render a Remote Compose document
    implementation("androidx.compose.remote:remote-player-core:1.0.0-alpha20")
    implementation("androidx.compose.remote:remote-player-view:1.0.0-alpha20")

    implementation("androidx.compose.remote:remote-tooling-preview:1.0.0-alpha20")
}

如需详细了解依赖项,请参阅添加 build 依赖项。

反馈

您的反馈将帮助我们改进 Jetpack。如果您发现了新问题,或对此库有任何改进建议,请告诉我们。创建新问题前,请先查看此库中的现有问题。您可以点击星标按钮,为现有问题投票。

创建新问题

如需了解详情,请参阅问题跟踪器文档。

版本 1.0

版本 1.0.0-alpha20

2026 年 9 月 23 日

发布了 androidx.compose.remote:remote-*:1.0.0-alpha20。版本 1.0.0-alpha20 中包含这些提交内容。

API 变更

  • 将 animateRemoteFloatAsState、animateRemoteDpAsState、RemoteAnimationSpec、RemoteModifier.sharedElement、RemoteModifier.sharedBounds 和 RemoteModifier.animateEnterExit 作为公共 API 进行公开 (I382ec)
  • 向 RemotePathScope 添加了 relative*To 命名别名和 quadraticTo/cubicTo 重载。(I4ebca)
  • 向 RemotePathScope 添加了形状辅助程序(addRect、addOval、addCircle、addRoundRect、addArc、addPath)和 RemoteOffset/RemoteSize 重载。(I14972)
  • 向 RemotePathScope 添加了支持 forceMoveTo 的 arcTo。(Ib5cf0)

bug 修复

  • 修复了以下问题:当存在子项时,CollapsibleColumnLayout 和 CollapsibleRowLayout minIntrinsicWidth/高度超出精确约束条件。(Ic2a6f)
  • 添加了新的 EventActionOperation,允许用户指定自定义事件处理程序。(I161bc)
  • 修复了按显示密度错误缩放名为 RemoteDp 的表达式的问题。(I78bf5)
  • androidx.lifecycle:lifecycle-runtime 依赖项已更新为 2.10.0。如果要在 AGP 9.5.0-alpha04 版或更高版本中运行捆绑的生命周期运行时 lint 检查,则必须使用此版本。(I99bfd、b/556807521)
  • 向 RemoteVectorPainter 和 RemoteImageVector 添加了画笔样式设置、Alpha、缠绕 (PathFillType) 和程序化绘制支持。(I7e69e)
  • 在远程 Compose 中添加了对动画矢量可绘制对象 (AVD) 的支持,并提供可注入的进度和默认的连续动画。(Ic0223)
  • 修复了使用 RemoteDp 记录填充和偏移修饰符时的性能回归问题。(Id8bc9、b/555795653)

版本 1.0.0-alpha19

2026 年 9 月 9 日

发布了 androidx.compose.remote:remote-*:1.0.0-alpha19。版本 1.0.0-alpha19 中包含这些提交内容。

API 变更

  • 将 conicTo 和 conicToRelative 添加到了 RemotePathScope 中。(Id49e5)
  • 向 remote-creation-compose 添加了 createProfile 帮助程序 (I92f5c)
  • 添加了 RemoteModifier.defaultMinSize。(If86a5)

bug 修复

  • 修复了远程组合修饰符、排列和形状中 RemoteDp 值的固定密度行为缩放。(I55bb7)
  • 修复了自动调整大小且居中/靠右对齐的复杂文本的水平对齐问题 (Ia4b9b)

版本 1.0.0-alpha18

2026 年 8 月 26 日

发布了 androidx.compose.remote:remote-*:1.0.0-alpha18。版本 1.0.0-alpha18 中包含这些提交内容。

API 变更

  • RemoteAbsoluteAlignment 现已公开,可在库组外部访问。(Id9ceb)
  • 在 RemoteTextStyle、RemoteText 和 RemoteTimeText 中添加了 fontFeatureSettings 和 fontVariationSettings 支持。(I6e78d、b/544644370)
  • 在 RemoteTextStyle 中添加了对 fontVariationSettings 的支持。(I2c44a、b/542047368)
  • RemoteCollapsibleColumn 和 RemoteCollapsibleRow 现在是公开的,可以在库组之外访问。(I5ec72)
  • RemoteFitBox(之前为 FitBox)现已公开,可在图书馆群组之外访问。(I689be)
  • 公开了 RemoteMatrix3x3 和 RemoteShaderBrush。applyTo,用于允许将矩阵转换应用于着色器。(I59594)
  • RemoteModifier.graphicsLayer 现在已公开,可在图书馆群组之外访问。(I59c2c)

bug 修复

  • 修复了 RemoteButton 和 RemoteCard 中的边框宽度缩放和对齐问题。(I8458b、b/544653389)
  • 修复了以下问题:在处理表达式或使用默认参数时,animateRemoteFloat 会舍弃动画规范。(I80e98、b/544687132)

版本 1.0.0-alpha17

2026 年 8 月 12 日

发布了 androidx.compose.remote:remote-*:1.0.0-alpha17。版本 1.0.0-alpha17 中包含这些提交内容。

API 变更

  • 将多个 RemoteCompose 单位和类型转换 API 升级为公开 API,包括 toRemoteFloat()、toRemoteLong()、toPx(density)、asRdp()、toRemoteDp()、asRemoteTextUnit() 和 toRsp()。(Idca36、b/465743273)
  • 将 RemoteDrawScope 中的 drawCircle、drawOval 和 drawLine 设为公开。(Iccf34、b/465743273)
  • 向 RemoteDp 添加了算术和比较运算。(I4b712、b/467023174)
  • 在 remote-creation-compose 中将 RemoteBrush、radialGradient 和 sweepGradient 公开为公共 API。(I24695、b/465743273)

其他

版本 1.0.0-alpha16

2026 年 7 月 29 日

发布了 androidx.compose.remote:remote-*:1.0.0-alpha16。版本 1.0.0-alpha16 中包含这些提交内容。

API 变更

  • 公开了 RemoteImageBitmap 的关联对象和调用工厂,以便在非可组合的上下文中从网址或 ImageBitmap 实例化远程图片位图。(I4dbc7)
  • 在 RemoteTextStyle 中公开 LineBreak 策略和断字频率(I7f2e6、b/510078059)
  • 将 RemotePaint 接口升级为公开接口。(Ida62b、b/465743273)
  • 移除了 RemoteFloat、RemoteInt 和 RemoteBoolean 中已废弃的简写比较运算符(eq、ne、lt、le、gt、ge)。(Ie01a9、b/532022248、b/532022248)

bug 修复

  • 修复了 RemoteText 中的行高计算以及 widthIn/heightIn 修饰符中的约束缩放。(I89814)
  • 修复了 RemoteComposePlayer 中的状态泄漏问题(I95630、b/531743466)

版本 1.0.0-alpha15

2026 年 7 月 15 日

发布了 androidx.compose.remote:remote-*:1.0.0-alpha15。版本 1.0.0-alpha15 中包含这些提交内容。

API 变更

  • 添加了 rememberRemoteImageBitmap(url) 并公开了 rememberMutableRemoteImageBitmap,以支持无名称的远程位图。(I7b960)
  • 公开了 RemoteStateScope.remotePath 和 RemotePathScope API,用于通过 DSL 构建路径。(I9e2fe、b/513228889)

bug 修复

版本 1.0.0-alpha14

2026 年 7 月 1 日

发布了 androidx.compose.remote:remote-*:1.0.0-alpha14。版本 1.0.0-alpha14 中包含这些提交内容。

API 变更

  • 在 RemoteCreationDisplayInfo 中公开了 RemoteDensityBehavior 和密度行为感知构造函数。(Iafca2、b/524921038)
  • 在 RemoteCreationDisplayInfo 和 RemoteComposeCreationState 中公开了 densityBehavior。(Iae938、b/524921038)
  • 将 RemoteComposeCreationComposeFlags 设为公开。(I1f899、b/467532762)

bug 修复

  • 添加了 Lint 检查,以针对在 @RemoteComposable 中使用标准 Compose CompositionLocals 的情况发出警告。(Ic12ba)
  • 移除了对 compileSdk 37 的要求 (If78b4)
  • 移除了过时的 rememberRemoteStringList 文档。(I99722)
  • 修复了当调整未定义时字体粗细调整的渲染问题。(I16704、b/522050705)
  • 将 BorderModifier 与 Compose 行为对齐,以便在组件边界内进行绘制。(Iae36c)
  • 修复了 RemoteComposeWriter,以在构造函数中序列化 DOC_PROFILES。(I3bbea)
  • 修复了 RemoteModifier.background 对动态颜色的原生支持。(If4f04、b/499049643)

功能 - 向 RemoteDocumentPlayer 添加了 typefaceResolver 参数。(Ie7cda, b/524621320) - 为 Compose 播放器添加了自定义组件支持。(Ic0559) - 优化了两种替代方案相同的选择操作。(I55b9e、b/390355362)

版本 1.0.0-alpha13

2026 年 6 月 17 日

发布了 androidx.compose.remote:remote-*:1.0.0-alpha13。版本 1.0.0-alpha13 中包含这些提交内容。

API 变更

  • 将 RemoteBitmap 重命名为 RemoteImageBitmap,以提高命名一致性。(I4fde1、b/513228889)
  • 将 RemoteBitmapShader 重命名为 RemoteImageBrush 并公开到公共 API。(I7adaf、b/513228889)
  • 公开了 RemoteInt 比较运算符。(I5fe3d、b/513228889)
  • 公开了 captureRemoteDocument Flow API 和新的 captureSingleRemoteDocument 重载(采用 RemoteCreationDisplayInfo)作为公共 API。(I87b0e、b/513228889)
  • 将 RemoteBoolean 上的比较运算符(eq、ne)重命名为 isEqualTo、isNotEqualTo。(Ia05b9、b/513228889)
  • 将 RemoteEnum 和 RemoteStateLayout 作为公共 API 进行公开 (I5c6ec)
  • 将 RemotePaint 接口中的 fontVariationSettings 属性公开为公共 API。(Ic3c46、b/513228889)
  • 移除了 RemoteInt 和 RemoteFloat toRemoteString 方法。(I62a6b、b/513228889)
  • 公开了 RemoteTypeface API。(Iadfdb、b/502907551)
  • 将现有的 ValueChange 工厂函数重命名为小写 valueChange。(I812b9、b/513228889)
  • 通过 lambda 延迟 PendingIntent 访问,并在预览模式下返回一个空操作,使 PendingIntentAction 在 IDE 预览中安全运行。(I43b37、b/512403924)

bug 修复

  • 引入 TypefaceResolver 和 DefaultTypefaceResolver 内部抽象,以实现字体解析的模块化。(Ia1df7、b/513228889)
  • 移除了过时的 RemoteIntReference 和 RemoteStringList API,并添加了 RemoteStringArray 以支持远程字符串数组。(I12931)
  • 将 LocalInspectionMode 传播到远程 Compose 捕获阶段(I6a56b、b/512403924)

版本 1.0.0-alpha12

2026 年 6 月 3 日

发布了 androidx.compose.remote:remote-*:1.0.0-alpha12。版本 1.0.0-alpha12 中包含这些提交内容。

API 变更

  • 修饰符 onTouchCancel(varargs action) 和 onTouchCancel(List<Action>) 已更改为 onTouchCancel(action)。使用 CombinedAction 表示一系列操作。(Ia7b5a、b/498881738)
  • 公开了 RemoteBoolean 静态工厂。(Ifedb6、b/484137042)
  • 公开了 hostAction 和 combinedAction 工厂函数,以允许外部使用。(I78002)
  • 添加了 RemoteContentPreview、RemoteDocumentPreview 和 RemotePreviewWrapper 函数,用于预览远程 Compose 内容。(I706ae、b/507379403)

版本 1.0.0-alpha11

2026 年 5 月 19 日

发布了 androidx.compose.remote:remote-*:1.0.0-alpha11。版本 1.0.0-alpha11 中包含这些提交内容。

API 变更

  • 公开了 RemoteInt 静态工厂。(Ic0096、b/484137042)
  • 公开了 RemoteState 静态工厂(I544f0、b/484137042)
  • RemoteLong 现在支持有限的算术运算符(加法、减法、乘法和截断转换为 RemoteInt)。(I1d416)
  • 更新了 RemoteText,以使用 RemoteFontFamily 而不是 FontFamily(Ib76b6、b/502907551)
  • 添加了 alpha、旋转和缩放修饰符。(I5d682、b/505427444)

版本 1.0.0-alpha010

2026 年 5 月 6 日

发布了 androidx.compose.remote:remote-*:1.0.0-alpha010。版本 1.0.0-alpha010 中包含这些提交内容。

功能

  • 添加了 EnforceCleanRecomposition 标志 (I6e4408)。为了支持 RemoteCompose 中的重组,我们已阻止在合成完成之前向文档写入任何内容。这样可以防止在重组期间部分写入文档。如果此行为导致现有代码出现问题,可以通过将 isEnforceCleanRecompositionEnabled 设置为 false 来停用此行为。

API 变更

bug 修复

  • 修复了使用 RemoteColor(而非静态颜色)作为背景颜色时出现的背景剪裁问题 (If70842、b/505116577)
  • 支持为从 URI 加载的位图提供明确的大小。之前,系统会将大小计算为 1x1,然后将该像素缩放到容器大小 (Id4fff, b/487936996)
  • 防止在没有 SensorManager 的设备上出现崩溃 bug (I1fc947、b/498302479)
  • 修复了 TIME_FROM 表达式未使用所提供时钟的问题(导致无法对时长表达式进行可靠的测试)(I5f816、b/501405389)

版本 1.0.0-alpha09

2026 年 4 月 22 日

发布了 androidx.compose.remote:remote-*:1.0.0-alpha09。版本 1.0.0-alpha09 中包含这些提交内容。

API 变更

  • 将修饰符 clickable 更改为不接受操作参数的 null 值。应改用 Action.Empty。(I21be9、b/498881738)
  • 内边距修饰符参数已从左/右更改为开始/结束。(Id781c、b/500760020)
  • 修饰符 onTouchDown(varargs action) 和 onTouchUp(varargs action) 已更改为 onTouchDown/onTouchUp(action)。使用 CombinedAction 表示一系列操作。(I8af9d、b/498881738)
  • 修饰符 clickable(varargs action) 已更改为 clickable(action)。使用 CombinedAction 表示一系列操作。(I8432d、b/498881738)

bug 修复

  • 修复了 MatrixExpression.write (Id3c52)

版本 1.0.0-alpha08

2026 年 4 月 8 日

发布了 androidx.compose.remote:remote-*:1.0.0-alpha08。版本 1.0.0-alpha08 中包含这些提交内容。

新功能

  • 将 CoreText、TextStyle、TextTransform 和 ColorTheme 操作提升为基准 AndroidX 和 widget 配置文件(I69671、b/494482597)
    • CoreText 可提供更丰富的文本呈现功能,包括自适应文本大小调整,以及对换行和溢出行为等文本布局功能的改进控制。
    • TextStyle 允许在文档中捕获一次通用文本样式属性,并由多个文本运行引用。
    • TextTransform 可实现文本转换,例如将文本转换为大写。
  • 当布局方向为 RTL 且未使用绝对水平排列时,反向渲染水平布局中的项。(I2d38e)

API 变更

  • 首选 toRemoteString(DecimalFormat) 作为开发者 API。(Ia4925、b/493924433)
  • 移除了修饰符 clip(shape, size)。应改用修饰符 clip(shape)。(I76301)

bug 修复

  • 更新 TextLookup 以跟踪数组元素更改。这样可确保,如果表达式在数组中查找的元素发生更改,系统会重新评估表达式 (I162c7)

版本 1.0.0-alpha07

2026 年 3 月 25 日

发布了 androidx.compose.remote:remote-*:1.0.0-alpha07。版本 1.0.0-alpha07 中包含这些提交内容。

新功能

  • 实现非线性字体缩放 (73b23c0)
  • 使布局能够识别 LayoutDirection (81f984b)

API 变更

版本 1.0.0-alpha06

2026 年 3 月 11 日

发布了 androidx.compose.remote:remote-*:1.0.0-alpha06。版本 1.0.0-alpha06 中包含这些提交内容。

新功能

  • 为 TextStyle 添加了一个新的实验性操作。TextStyle 可让常用排版样式一次性写入文档,并由多个文本运行 (bfc6487) 重复使用

API 变更

  • 公开 RemoteTextStyle 合并(I971ce、b/446824085)
  • 将 RemotePainter 公开为公共 API(I252c1、b/446824085)
  • 公开了 Border/Clip 修饰符和 RemoteShape。(Id26dd、b/446824085)
  • 在 remote-creation-compose 中公开了 RemoteColor API(I4ab00、b/446824085)
  • 公开了 RemoteText API (I6b019)
  • 公开了 RemoteImage API (Ided31)
  • 公开了 RemoteBoolean、RemoteString 和 RemoteFloat API (Id9ee6)
  • 来自 WidthIn 注解的远程可组合项 (I80784)

bug 修复

  • 将库迁移为使用 Java 11 目标平台。这意味着生成的字节码将是 Java 11(类文件版本 55),可能需要进行 desugaring 才能使用该库(If4c2a、b/457821470)
    • 确保长度和 textlookup 正确更新。之前,RemoteStrings 的长度会在第一帧上计算,之后不会更新 (e49cb53)
    • 支持具有较大分数部分的数字的 TextFromFloat。之前,较大的“digitsAfter”值可能会导致浮点数评估为 0 (5080bc54)

版本 1.0.0-alpha05

2026 年 2 月 25 日

发布了 androidx.compose.remote:remote-*:1.0.0-alpha05。版本 1.0.0-alpha05 中包含这些提交内容。

新功能

  • 推出了 fillParentMaxWidth 和 fillParentMaxHeight。(4c6d77c)

API 变更

  • 公开了常见的远程可组合项和修饰符类型 (Id1d40)
  • 公开了 RemoteState 的类型(I22429、b/465453482)

bug 修复

  • 修复了滚动问题 (0a25299)
  • 修复了触控容差问题 (0192b69)
  • 在渲染过程中更早地设置密度,以便在第一帧(通常在屏幕截图测试中捕获)上正确应用密度 (f775399)

版本 1.0.0-alpha04

2026 年 2 月 11 日

发布了 androidx.compose.remote:remote-*:1.0.0-alpha04。版本 1.0.0-alpha04 中包含这些提交内容。

新功能

  • 默认使用 RemoteApplier 启用,这样可以防止在创建远程界面时使用非远程可组合函数。您可以通过更改 RemoteComposeCreationComposeFlags 中的 isRemoteApplierEnabled 来停用此功能。(67a405f)
  • 为位图字体添加字形间距 (0852657)
  • 在 RemoteCanvas 中旋转(使用透视)(9a292b3)
  • 添加了 RemoteSpacer (12beb72)
  • 避免了 java.time 依赖项,从而将创建库的 minSdk 降至 23 (59e30d0)
  • FlowLayout (7efef02)

bug 修复

  • 修复了非全局 ColorExpression 和计算出的字符串的评估。(c08d0bd)

外部贡献

  • androidx.compose.ui.graphics.NativePaint 类型别名已废弃,请直接使用 android.graphics.Paint(I6303c、b/477394763)
  • 将 Paint.asFrameworkPaint() 替换为 Paint.nativePaint 扩展,以避免通过 typealias 将平台类型暴露到 commonMain sourceset 中(I6303c、b/477394763)

版本 1.0.0-alpha03

2026 年 1 月 28 日

发布了 androidx.compose.remote:remote-*:1.0.0-alpha03。版本 1.0.0-alpha03 中包含这些提交内容。

新功能

  • 支持 BorderModifier 中不同的形状和 RemoteColors 0afd343
  • 添加 CombinedAction 以支持点击事件的多个操作 10e16a2

API 变更

  • 迁移了 RemoteColor 和 RemoteBitmap 的 API,以使用 Compose 类型,而不是直接公开 Android 类型 a9bfbb8
  • 引入 RemoteDensity 类型,以确定是在播放器上评估密度(当为远程设备生成文档时),还是内联表达式(以优化同一设备上的文档大小)54352bb
  • RemoteState constantValueOrNull 重命名(I6ad5c、b/467050397)

版本 1.0.0-alpha02

2026 年 1 月 14 日

发布了 androidx.compose.remote:remote-*:1.0.0-alpha02。版本 1.0.0-alpha02 中包含这些提交内容。

新功能

  • 为 CoreText 添加了最小/最大字号。I7bd3c

API 变更

bug 修复

  • 修复了重新布局后的滚动位置问题,并添加了对边缘效果的支持 (6d4551)

版本 1.0.0-alpha01

2025 年 12 月 17 日

发布了 androidx.compose.remote:remote-*:1.0.0-alpha01。版本 1.0.0-alpha01 中包含这些提交内容。

  • Remote Compose 是一个用于为远程 surface 创建界面的框架。