条件


提供比较逻辑,用于有条件地启用子元素的外观、动画和事件处理。

此元素在 Wear OS 4 中推出。

语法

<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>

内部元素

Condition 元素包含以下内部元素:

Expressions

定义一组 Expression 元素,每个元素具有 name 属性且包含算术表达式name 在包含的 Condition 元素中必须是唯一的。

一个 Condition 元素必须包含至少一个 Expressions 元素。

Compare

含有单一元素树,且只有在具有指定名称的表达式求值为 true 或非零值时,该树才会显示、呈现动画效果并能接收事件。name 属性必须与 Condition 元素中其他位置使用的 Expression 元素的 name 属性匹配。

Default

含有单一元素树,且只有在所有 Compare 元素群组均未启用时,该树才会显示、呈现动画效果并能接收事件。

目前没有任何推荐文档页面。

请尝试您的 Google 账号。