写真でカスタマイズする
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
注: この機能は、ウォッチフェイス フォーマットのバージョン 4 以降で利用できます。
ユーザーがウォッチフェイスに表示する写真を選択できるようにすると、ウォッチフェイスの使用感をパーソナライズできます。
ウォッチフェイスに画像を表示する方法については、画像の操作のセクションですでに説明しています。ユーザーが事前定義された一連の画像から選択できるようにするには、ユーザー構成を定義するセクションで説明されているように ListConfiguration
を使用します。
ユーザーが設定できる画像をウォッチフェイスで使用する場合は、<PhotosConfiguration>
要素を使用します。次に例を示します。
<UserConfigurations>
<PhotosConfiguration id="photoConfig" configType="SINGLE"/>
</UserConfigurations>
configType
は SINGLE
または MULTIPLE
のいずれかです。これは、ユーザーがコンパニオン内の 1 枚の画像を選択できるか、写真のコレクションを選択できるかを指定します。
1 枚の写真をサポートする
単一画像の場合、写真は次のように 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
の使用時に導入される 2 つのオプションを示しています。
change
属性を使用すると、利用可能な画像を写真で切り替えるイベントを指定できます。
上の例では、TAP
と ON_VISIBLE
の両方が指定されています。つまり、ユーザーが写真をタップしたとき、または写真が表示されたときに、写真が変化します。
changeAfterEvery
属性は ON_VISIBLE
変更イベントにのみ適用され、写真が変更される前に写真が表示される必要がある回数を指定します。たとえば、ユーザーがスマートウォッチを起動するたびに写真を変更するのは頻度が高すぎると判断される場合があります。デフォルト値は 3 です。
PhotosConfiguration
の使用方法について詳しくは、GitHub のサンプルをご覧ください。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-07-27 UTC。
[[["わかりやすい","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"]],["最終更新日 2025-07-27 UTC。"],[],[],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."]]