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
- Note: link text is displayed when JavaScript is off
- Features and APIs Overview
- Variant
- Layouts and binding expressions