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.
Recommended for you
Note: link text is displayed when JavaScript is off
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-06-26 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-06-26 UTC."],[],[],null,["# Condition\n\nWatch Face Format version Version 4 Version 3 Version 2 Version 1\n\n*** ** * ** ***\n\nProvides comparison logic for conditionally enabling the appearance, animation,\nand event handling of child elements.\n\nIntroduced in Wear OS 4.\n\nSyntax\n------\n\n```xml\n\u003cCondition\u003e\n \u003c!-- The \"Expressions\" element is required. --\u003e\n \u003cExpressions\u003e\n \u003cExpression name=\"unique-name\"\u003e\n \u003c!-- Arithmetic expression goes here. --\u003e\n \u003c/Expression\u003e\n \u003c!-- Other expressions go here. --\u003e\n \u003c/Expressions\u003e\n \u003c!-- The \"expression\" attribute is required. --\u003e\n \u003cCompare expression=\"expression-name\"\u003e\n \u003c!-- ONE of the following only: --\u003e\n \u003cGroup ... /\u003e\n \u003cPartText ... /\u003e\n \u003cPartImage ... /\u003e\n \u003cPartAnimatedImage ... /\u003e\n \u003cPartDraw ... /\u003e\n \u003cCondition ... /\u003e\n \u003cAnalogClock ... /\u003e\n \u003cDigitalClock ... /\u003e\n \u003c/Compare\u003e\n \u003c!-- The \"else\" case for when all of the above \"Compare\"\n conditions are false. --\u003e\n \u003cDefault\u003e\n \u003c!-- ONE of the following only: --\u003e\n \u003cGroup ... /\u003e\n \u003cPartText ... /\u003e\n \u003cPartImage ... /\u003e\n \u003cPartAnimatedImage ... /\u003e\n \u003cPartDraw ... /\u003e\n \u003cCondition ... /\u003e\n \u003cAnalogClock ... /\u003e\n \u003cDigitalClock ... /\u003e\n \u003c/Default\u003e\n\u003c/Condition\u003e\n```\n\nInner elements\n--------------\n\nThe `Condition` element contains the following inner elements:\n\n`Expressions`\n\n: Defines a set of `Expression` elements that each have a `name` attribute and\n contain an [arithmetic expression](/training/wearables/wff/common/attributes/arithmetic-expression). The `name` must be unique within the\n containing `Condition` element.\n\n A `Condition` element must contain at least one `Expressions` element.\n\n`Compare`\n\n: Contains a single element tree that is visible, animated, and receptive to\n events only if the expression with the given name evaluates to `true` or a\n non-zero value. The `name` attribute must match the `name` attribute of an\n `Expression` element used elsewhere in the `Condition` element.\n\n`Default`\n\n: Contains a single element tree that is visible, animated, and receptive to\n events only when none of the `Compare` element groups are activated.\n\nRecommended for you\n-------------------\n\n- Note: link text is displayed when JavaScript is off\n- [AGSL Quick Reference](/develop/ui/views/graphics/agsl/agsl-quick-reference)\n- [Define data using Room entities](/training/data-storage/room/defining-data)\n- [Data Binding in Android](/codelabs/android-databinding)"]]