Reference
Stay organized with collections
Save and categorize content based on your preferences.
Allows elements in the watch face scene to dynamically adjust based on
attributes from other elements elsewhere in the watch face scene.
Introduced in Wear OS 6.
Syntax
Reference
allows the attributes of one scene element to dynamically follow
those of another. For example, the position or size of a PartDraw
element
could automatically adjust based on the position or size of a PartText
element
elsewhere in the scene graph.
The Reference
element can be placed under any scene object supporting
Transform
. As an example, to create a reference to the x
attribute of a
PartText
element, which itself is being dynamically adjusted:
<PartText x="0" y="0" width="200" height="50">
<Transform target="x" value="... some expression ..." />
<Reference name="headerPosition" source="x" defaultValue="0" />
</PartText>
Use this elsewhere in the watch face scene, for example in a PartDraw
:
<PartDraw x="0" y="100" width="200" height="100">
<Transform target="x" value="[REFERENCE.headerPosition]" />
</PartText>
Using both of the above, the x
position of the PartText
is adjusted
dynamically through the use of the Transform
, and then shared for use by other
elements by the inclusion of the Reference
element. The PartDraw
element
makes use of this value, therefore keeping the PartText
and PartDraw
x
positions synchronized.
Attributes
The following attributes are required:
name
- The name of the reference. This should be unique within the XML document.
source
- One of the transformable attributes of the parent element.
defaultValue
- The value that will be used while the parent element is not available such As
when it is not visible.
Recommended for you
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-05-20 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-05-20 UTC."],[],[],null,["# Reference\n\nAllows elements in the watch face scene to dynamically adjust based on\nattributes from other elements elsewhere in the watch face scene.\n\nIntroduced in Wear OS 6.\n\nSyntax\n------\n\n`Reference` allows the attributes of one scene element to dynamically follow\nthose of another. For example, the position or size of a `PartDraw` element\ncould automatically adjust based on the position or size of a `PartText` element\nelsewhere in the scene graph.\n\nThe `Reference` element can be placed under any scene object supporting\n`Transform`. As an example, to create a reference to the `x` attribute of a\n`PartText` element, which itself is being dynamically adjusted: \n\n \u003cPartText x=\"0\" y=\"0\" width=\"200\" height=\"50\"\u003e\n \u003cTransform target=\"x\" value=\"... some expression ...\" /\u003e\n \u003cReference name=\"headerPosition\" source=\"x\" defaultValue=\"0\" /\u003e\n \u003c/PartText\u003e\n\nUse this elsewhere in the watch face scene, for example in a `PartDraw`: \n\n \u003cPartDraw x=\"0\" y=\"100\" width=\"200\" height=\"100\"\u003e\n \u003cTransform target=\"x\" value=\"[REFERENCE.headerPosition]\" /\u003e\n \u003c/PartText\u003e\n\nUsing both of the above, the `x` position of the `PartText` is adjusted\ndynamically through the use of the `Transform`, and then shared for use by other\nelements by the inclusion of the `Reference` element. The `PartDraw` element\nmakes use of this value, therefore keeping the `PartText` and `PartDraw` `x`\npositions synchronized.\n\nAttributes\n----------\n\nThe following attributes are required:\n\n`name`\n: The name of the reference. This should be unique within the XML document.\n\n`source`\n: One of the transformable attributes of the parent element.\n\n`defaultValue`\n: The value that will be used while the parent element is not available such As\n when it is not visible.\n\nRecommended for you\n-------------------\n\n- Note: link text is displayed when JavaScript is off\n- [Features and APIs Overview](/about/versions/11/features)\n- [Variant](/training/wearables/wff/common/variant/variant)\n- [Layouts and binding expressions](/topic/libraries/data-binding/expressions)"]]