从版本 1.2 开始,大多数功能块布局 API 都位于 androidx.wear.protolayout
命名空间中。如需使用最新的 API,请在代码中完成以下迁移步骤。
更新依赖项
在应用模块的 build 文件中,进行以下更改:
// Remove
implementation 'androidx.wear.tiles:tiles-material:version '
// Include additional dependencies
implementation "androidx.wear.protolayout:protolayout:1.3.0-alpha03"
implementation "androidx.wear.protolayout:protolayout-material:1.3.0-alpha03"
implementation "androidx.wear.protolayout:protolayout-expression:1.3.0-alpha03"
// Update
implementation "androidx.wear.tiles:tiles:1.5.0-alpha03"
// Remove
implementation("androidx.wear.tiles:tiles-material:version ")
// Include additional dependencies
implementation("androidx.wear.protolayout:protolayout:1.3.0-alpha03")
implementation("androidx.wear.protolayout:protolayout-material:1.3.0-alpha03")
implementation("androidx.wear.protolayout:protolayout-expression:1.3.0-alpha03")
// Update
implementation("androidx.wear.tiles:tiles:1.5.0-alpha03")
更新命名空间
在应用的 Kotlin 和 Java 代码文件中,进行以下更新。或者,您也可以执行此命名空间重命名脚本。
- 将所有
androidx.wear.tiles.material.*
导入内容都替换为androidx.wear.protolayout.material.*
。另外也针对androidx.wear.tiles.material.layouts
库完成此步骤。 将大多数其他
androidx.wear.tiles.*
导入内容替换为androidx.wear.protolayout.*
。androidx.wear.tiles.EventBuilders
、androidx.wear.tiles.RequestBuilders
、androidx.wear.tiles.TileBuilders
和androidx.wear.tiles.TileService
的导入内容应保持不变。重命名 TileService 和 TileBuilder 类中的一些已废弃的方法:
TileBuilders
:将getTimeline()
重命名为getTileTimeline()
,将setTimeline()
重命名为setTileTimeline()
TileService
:将onResourcesRequest()
重命名为onTileResourcesRequest()
RequestBuilders.TileRequest
:将getDeviceParameters()
重命名为getDeviceConfiguration()
,将setDeviceParameters()
重命名为setDeviceConfiguration()
,将getState()
重命名为getCurrentState()
,将setState()
重命名为setCurrentState()
目前没有任何推荐文档页面。
请尝试登录您的 Google 账号。