BooleanConfiguration

布尔值配置为用户提供了在表盘编辑器中自定义表盘时可以开启或关闭的选项。

此元素在 Wear OS 4 中推出。

语法

<BooleanConfiguration id="string" displayName="string" icon="string"
                         screenReaderText="string" defaultValue="TRUE | FALSE"
/>

您可以在 Scene 元素中包含一个 BooleanConfiguration 元素,如以下代码段所示:

<UserConfigurations>
  <BooleanConfiguration id="show_date"
      displayName="@string/show_date_label"
      screenReaderText="@string/show_date_label"
      defaultValue="TRUE"
  />
</UserConfigurations>

<!-- ... -->

<Scene backgroundColor="#ff000000">
  <!-- ... -->

  <BooleanConfiguration id="show_date">
    <BooleanOption id="TRUE">
      <Group ...>
        <!-- ...Content to show date -->
      </Group>
    </BooleanOption>
    <BooleanOption id="FALSE">
      <Group ...>
        <!-- ...Content when date not required -->
      </Group>
    </BooleanOption>
  </BooleanConfiguration>

  <!-- ... -->
</Scene>

属性

BooleanConfiguration 元素具有以下属性:

必需属性

以下属性是必需属性:

id
配置值的唯一标识符。
displayName
与表盘编辑器中显示的文本对应的资源 ID。
defaultValue
如果用户没有在表盘编辑器中明确更改配置,则使用默认配置值。

可选属性

以下属性是可选属性:

icon
与表盘编辑器中显示的可绘制资源对应的资源 ID。其最大尺寸应为 400x400 像素。
screenReaderText
与用户已启用 TalkBack 时使用的文本对应的资源 ID。