迁移基于 View 的现有应用
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Jetpack Compose 从设计之初就考虑到了 View 互操作性,您可以在 View 中使用 Compose,反之亦然。借助此功能,您可以在基于 View 的现有应用中采用 Compose,而不必从头开始重写该应用。
以下页面介绍了如何将 Compose 与现有应用集成:
- 迁移策略:了解以安全的方式逐步将 Compose 引入代码库的策略。
- Interoperability API:了解 Compose 的 API 如何帮助您将 Compose 与基于 View 的界面合并。
- 其他注意事项:了解将基于 View 的应用迁移到 Compose 时如何考虑主题设置、架构和测试等其他注意事项。
示例
以下示例展示了 Jetpack Compose 与 View 的互操作性:
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-21。
[null,null,["最后更新时间 (UTC):2025-08-21。"],[],[],null,["# Migrate existing View-based apps\n\nJetpack Compose was designed with View interoperability right from the start---you\ncan use Compose within Views, and vice versa. This functionality allows you\nto adopt Compose in your existing View-based app without having to rewrite it\nfrom scratch.\n\nThe following pages describe how to integrate Compose with your existing apps:\n\n- [Migration strategy](/develop/ui/compose/migrate/strategy): Learn the strategy to safely and incrementally introduce Compose into your codebase.\n- [Interoperability APIs](/develop/ui/compose/migrate/interoperability-apis): Learn about Compose's APIs to help you combine Compose with View-based UI.\n- [Other considerations](/develop/ui/compose/migrate/other-considerations): Learn other considerations like theming, architecture, and testing while migrating your View-based app to Compose.\n\n#### Samples\n\nThe following samples demonstrate Jetpack Compose and View interoperability:"]]