将 XML 主题迁移到 Compose
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
在现有应用中引入 Compose 时,您需要迁移 XML 中的主题,才能对 Compose 界面使用 MaterialTheme
。这意味着应用主题将有两个可信来源:基于 View 的主题和 Compose 主题。对样式所做的任何更改都需要在多个位置进行。应用完全迁移到 Compose 后,您就可以移除 XML 主题了。
如需将 XML 主题迁移到 Compose,请使用 Material 主题构建器,在 Compose 中从 XML 主题迁移到 Material 3。您可以使用现有的颜色角色(例如 XML 主题中的主色和辅色),并将其传递给 Material Theme Builder。这会在 Compose 中创建完全 Material 3 主题,并提供可下载的颜色和主题文件以在您的应用中使用。
Material Theme Builder 会为您的应用生成 MaterialTheme
以及浅色和深色配色方案。如果您的应用使用自定义形状或排版,请分别通过定义 Shape
和 Typography
来迁移自定义形状和排版。定义后,请将该信息提供给您的 MaterialTheme
。如需了解详情,请参阅形状和排版。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-07-11。
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"没有我需要的信息"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"太复杂/步骤太多"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"内容需要更新"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"翻译问题"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"示例/代码问题"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"其他"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"易于理解"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"解决了我的问题"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"其他"
}]
{
"last_modified": "最后更新时间 (UTC):2024-07-11。",
"state": ""
}