Allows watch face developers to specify a string format, such as %s %d. The string format is very similar to printf() in the C programming language or String.format() in the Java programming language.

Additionally, Template allows the developer to use Android string resources, including the ones declared in res/values/strings.xml.

Introduced in Wear OS 4.


    <Parameter expression="arithmetic-expression" />


The following code snippet shows how to print the string Current heart rate: 80 using the Template and Parameter elements:

<Template>%s %d
    <Parameter expression="Current heart rate: " />
    <Parameter expression="[HEART_RATE]" />

This code snippet shows how to use an Android string resource to print the string Day: Fri:

    <Parameter expression="[DAY_OF_WEEK_S]" />

where day_of_week is defined in res/values/strings.xml:

    <string name="day_of_week">Day: %1$s</string>

Inner elements

The Template element must contain at least one Parameter inner element. The Parameter inner element has one attribute, expression, that is an arithmetic expression whose value is converted to a specific type according to the Template element's format string. The expressions in the different Parameter inner elements are evaluated left-to-right in the Template element's format string.