Complication 元素可定義特定小工具類型在錶面上的顯示方式。
針對每種小工具類型,您可以在運算式中使用下列程式碼,存取提供給小工具的資料:
- 所有類型和
EMPTY
:[COMPLICATION.TYPE]
[COMPLICATION.TAP_ACTION]
LONG_TEXT
:[COMPLICATION.MONOCHROMATIC_IMAGE]
[COMPLICATION.MONOCHROMATIC_IMAGE_AMBIENT]
[COMPLICATION.TEXT]
[COMPLICATION.TITLE]
MONOCHROMATIC_IMAGE
:[COMPLICATION.MONOCHROMATIC_IMAGE]
[COMPLICATION.MONOCHROMATIC_IMAGE_AMBIENT]
PHOTO_IMAGE
:[COMPLICATION.PHOTO_IMAGE]
RANGED_VALUE
:[COMPLICATION.MONOCHROMATIC_IMAGE]
[COMPLICATION.MONOCHROMATIC_IMAGE_AMBIENT]
[COMPLICATION.TEXT]
[COMPLICATION.TITLE]
[COMPLICATION.RANGED_VALUE_MIN]
[COMPLICATION.RANGED_VALUE_MAX]
[COMPLICATION.RANGED_VALUE_VALUE]
[COMPLICATION.RANGED_VALUE_COLORS]
- (以空格分隔十六進位的清單 顏色,例如#FF0000 #00FF00
)[COMPLICATION.RANGED_VALUE_COLORS_INTERPOLATE]
- (用於指定布林值的布林值 是否插入顏色)
SHORT_TEXT
:[COMPLICATION.MONOCHROMATIC_IMAGE]
[COMPLICATION.MONOCHROMATIC_IMAGE_AMBIENT]
[COMPLICATION.TEXT]
[COMPLICATION.TITLE]
SMALL_IMAGE
:[COMPLICATION.SMALL_IMAGE]
[COMPLICATION.SMALL_IMAGE_AMBIENT]
[COMPLICATION.IMAGE_STYLE]
- (對應至SmallImageType
序數值)
GOAL_PROGRESS
:[COMPLICATION.GOAL_PROGRESS_VALUE]
[COMPLICATION.GOAL_PROGRESS_TARGET_VALUE]
[COMPLICATION.TEXT]
[COMPLICATION.TITLE]
[COMPLICATION.GOAL_PROGRESS_COLORS]
- (以空格分隔十六進位的清單 顏色,例如#FF0000 #00FF00
)[COMPLICATION.GOAL_PROGRESS_COLORS_INTERPOLATE]
- (用於指定布林值的布林值 是否插入顏色)
WEIGHTED_ELEMENTS
:[COMPLICATION.WEIGHTED_ELEMENTS_COLORS]
- (以空格分隔十六進位的清單 顏色,例如#FF0000 #00FF00
)[COMPLICATION.WEIGHTED_ELEMENTS_WEIGHTS]
- (以空格分隔的清單) 元素權重)[COMPLICATION.WEIGHTED_ELEMENTS_BACKGROUND_COLOR]
[COMPLICATION.TEXT]
[COMPLICATION.TITLE]
如需完整示範,請參閱「範例」一節。
這項元素已在 Wear OS 4 推出。
語法
<Complication type="string"> <!-- Only the most common inner element is shown here. --> <Group> </Group> </Complication>
範例
以下範例為包含圖片、標題和文字元件的小工具:
<Complication type="SHORT_TEXT">
<PartImage x="35" y="16" width="22" height="22" pivotX="0.5" pivotY="0.5"
name="SomeIcon" alpha="255">
<Image resource="[COMPLICATION.MONOCHROMATIC_IMAGE]"/>
</PartImage>
<PartText x="18" y="39" width="56" height="22" pivotX="0.5" pivotY="0.5"
name="SomeText" alpha="255">
<Text align="CENTER" ellipsis="TRUE">
<Font family="SYNC_TO_DEVICE" size="20" weight="NORMAL"
slant="NORMAL" color="#ffffffff">
<Template>
%s
<Parameter expression="[COMPLICATION.TEXT]"/>
</Template>
</Font>
</Text>
</PartText>
<PartText x="19" y="62" width="54" height="14" pivotX="0.5" pivotY="0.5"
name="SomeTitle" alpha="255">
<Text align="CENTER" ellipsis="TRUE">
<Font family="SYNC_TO_DEVICE" size="12" weight="NORMAL"
slant="NORMAL" color="#ffadadad">
<Template>
%s
<Parameter expression="[COMPLICATION.TITLE]"/>
</Template>
</Font>
</Text>
</PartText>
</Complication>
屬性
ComplicationSlot
元素必須包含 type
屬性。如果使用者選擇相符的小工具類型,系統就會算繪該元素。支援的值為 SHORT_TEXT
、LONG_TEXT
、MONOCHROMATIC_IMAGE
、SMALL_IMAGE
、PHOTO_IMAGE
、RANGED_VALUE
和 EMPTY
。
內部元素
Complication
元素可包含任意數量的下列內部元素:
為您推薦
- 注意:系統會在 JavaScript 關閉時顯示連結文字
- WeightedStroke
- WeightedStroke
- ComplicationSlot