使用照片进行个性化设置
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
注意:此功能适用于表盘格式 4 及更高版本。
允许用户选择要添加到表盘主题中的照片,有助于为表盘主题体验增添个人风格。
使用图片部分已介绍如何在表盘中显示图片。如果您想允许用户从一系列预定义图片中进行选择,请使用 ListConfiguration
,如定义用户配置部分所示。
如需在表盘中使用用户可以配置的图片,请使用 <PhotosConfiguration>
元素,例如:
<UserConfigurations>
<PhotosConfiguration id="photoConfig" configType="SINGLE"/>
</UserConfigurations>
configType
可以是 SINGLE
或 MULTIPLE
,表示用户能否在随播广告中选择单张图片或一组照片。
支持单张照片
对于单张图片用例,可以在 PartImage
元素中使用照片,如下所示:
<PartImage ...>
<Photos source="[CONFIGURATION.photoConfig]" defaultImageResource="default_image"/>
</PartImage>
请注意 defaultImageResource
,它会在用户未在配套应用中选择照片时显示,并且是必需属性。
如果用户想选择其他照片,则必须使用配套应用将现有选择替换为其他照片。
支持多张照片
将 PhotosConfiguration
与 configType="MULTIPLE"
搭配使用可让表盘显示某个合集中的照片,用户可以通过点按来轮播这些照片,也可以在观看了一定次数后自动轮播。
<Photos change="ON_VISIBLE TAP" changeAfterEvery="5"
source="[CONFIGURATION.photoConfig]" defaultImageResource="default_image"/>
上面的示例展示了使用 MULTIPLE
时引入的两个选项:
- 借助
change
属性,开发者可以指定哪些事件应导致照片轮播可用图片。
在上例中,同时指定了 TAP
和 ON_VISIBLE
,这意味着照片会在用户点按照片或照片变为可见时发生变化。
changeAfterEvery
属性仅适用于 ON_VISIBLE
更改事件,用于指定照片在更改之前应显示的次数。例如,您可能认为每次用户唤醒手表时更改照片的频率过高。此处的默认值为 3。
如需详细了解如何使用 PhotosConfiguration
,请参阅 GitHub 上的示例。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Personalize with photos\n\n**Note**: This feature is available on version 4 and higher of Watch Face\nFormat.\n\nAllowing the user to select photos for inclusion on the watch face can help\nbring a personal touch to your watch face experience.\n\nThe [working with images](/training/wearables/wff/images) section already covers how to display images in\nyour watch face. If you want to allow the user to choose from a range of\npredefined images, then use a `ListConfiguration` as shown in the [define user\nconfigurations](/training/wearables/wff/personalization/user-configurations) section.\n\nTo use images in your watch face that the user can configure, use the\n`\u003cPhotosConfiguration\u003e` element, for example: \n\n \u003cUserConfigurations\u003e\n \u003cPhotosConfiguration id=\"photoConfig\" configType=\"SINGLE\"/\u003e\n \u003c/UserConfigurations\u003e\n\nThe `configType` can be either `SINGLE` or `MULTIPLE` indicating whether the\nuser will be able to select a single image within the companion or a collection\nof photos.\n\nSupport a single photo\n----------------------\n\nFor the single image case, the photo can be used within a `PartImage` element as\nfollows: \n\n \u003cPartImage ...\u003e\n \u003cPhotos source=\"[CONFIGURATION.photoConfig]\" defaultImageResource=\"default_image\"/\u003e\n \u003c/PartImage\u003e\n\nNote the `defaultImageResource`, which is shown when the user has not\nselected a photo in the companion and is a required attribute.\n\nIf the user wishes to select a different photo, then they must use the companion\nto replace the existing selection with another.\n\nSupport multiple photos\n-----------------------\n\nUsing `PhotosConfiguration` with `configType=\"MULTIPLE\"` allows the watch face\nto display a photo from a collection, which can be cycled through either through\ntapping or automatically after so many views have taken place. \n\n \u003cPhotos change=\"ON_VISIBLE TAP\" changeAfterEvery=\"5\"\n source=\"[CONFIGURATION.photoConfig]\" defaultImageResource=\"default_image\"/\u003e\n\nThe preceding example shows the two options that are introduced when using\n`MULTIPLE`:\n\n1. The `change` attribute allows the developer to specify what events should cause the photo to cycle through the available images.\n\nIn the preceding example, both `TAP` and `ON_VISIBLE` are specified, meaning\nthat the photo changes in response *either* to a user tapping the photo *or*\nin response to the photo becoming visible.\n\n1. The `changeAfterEvery` attribute applies only to the `ON_VISIBLE` change event, specifing how many times the photo should have become visible before the photo is changed. For example, you may feel that changing the photo every time the user wakes their watch is too frequent. The default value here is 3.\n\nFor more details on working with `PhotosConfiguration`, see the samples on\nGitHub."]]