Condition

Provides comparison logic for conditionally enabling the appearance, animation, and event handling of child elements.

Introduced in Wear OS 4.

Syntax

<Condition>
    <!-- The "Expressions" element is required. -->
    <Expressions>
        <Expression name="unique-name">
            <!-- Arithmetic expression goes here. -->
        </Expression>
        <!-- Other expressions go here. -->
    </Expressions>
    <!-- The "expression" attribute is required. -->
    <Compare expression="expression-name">
        <!-- ONE of the following only: -->
        <Group ... />
        <PartText ... />
        <PartImage ... />
        <PartAnimatedImage ... />
        <PartDraw ... />
        <Condition ... />
        <AnalogClock ... />
        <DigitalClock ... />
    </Compare>
    <!-- The "else" case for when all of the above "Compar e"
         conditions are false. -->
    <Default>
        <!-- ONE of the following only: -->
        <Group ... />
        <PartText ... />
        <PartImage ... />
        <PartAnimatedImage ... />
        <PartDraw ... />
        <Condition ... />
        <AnalogClock ... />
        <DigitalClock ... />
    </Default>
</Condition>

Inner elements

The Condition element contains the following inner elements:

Expressions

Defines a set of Expression elements that each have a name attribute and contain an arithmetic expression. The name must be unique within the containing Condition element.

A Condition element must contain at least one Expressions element.

Compare

Contains a single element tree that is visible, animated, and receptive to events only if the expression with the given name evaluates to true or a non-zero value. The name attribute must match the name attribute of an Expression element used elsewhere in the Condition element.

Default

Contains a single element tree that is visible, animated, and receptive to events only when none of the Compare element groups are activated.