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 "Compare" 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 - Expressionelements that each have a- nameattribute and contain an arithmetic expression. The- namemust be unique within the containing- Conditionelement.- A - Conditionelement must contain at least one- Expressionselement.
- Compare
- Contains a single element tree that is visible, animated, and receptive to events only if the expression with the given name evaluates to - trueor a non-zero value. The- nameattribute must match the- nameattribute of an- Expressionelement used elsewhere in the- Conditionelement.
- Default
- Contains a single element tree that is visible, animated, and receptive to events only when none of the - Compareelement groups are activated.
Recommended for you
- Note: link text is displayed when JavaScript is off
- AGSL Quick Reference
- Define data using Room entities
- Data Binding in Android
