ComplicationSlotBounds


Note: As of July 10, 2024, watch faces must use the Watch Face Format in order to be installed on new watches that launch with Wear OS 5 pre-installed. Learn more about the user-facing changes in this Help Center article.

Additionally, starting in early 2025 (specific date to be announced during Q4 2024), all new watch faces published on Google Play must use the Watch Face Format.

class ComplicationSlotBounds


ComplicationSlotBounds are defined by fractional screen space coordinates in unit-square 0..1. These bounds will be subsequently clamped to the unit square and converted to screen space coordinates. NB 0 and 1 are included in the unit square.

One bound is expected per ComplicationType to allow androidx.wear.watchface.ComplicationSlots to change shape depending on the type.

Taps on the watch are tested first against each ComplicationSlot's perComplicationTypeBounds for the relevant ComplicationType. Its assumed that perComplicationTypeBounds don't overlap. If no intersection was found then taps are checked against perComplicationTypeBounds expanded by perComplicationTypeMargins. Expanded bounds can overlap so the ComplicationSlot with the lowest id that intersects the coordinates, if any, is selected.

Summary

Public constructors

ComplicationSlotBounds(
    perComplicationTypeBounds: Map<ComplicationTypeRectF>
)

This function is deprecated. Use a constructor that specifies perComplicationTypeMargins

ComplicationSlotBounds(bounds: RectF, margins: RectF)

Constructs a ComplicationSlotBounds where all complication types have the same screen space unit-square bounds and margins.

ComplicationSlotBounds(
    perComplicationTypeBounds: Map<ComplicationTypeRectF>,
    perComplicationTypeMargins: Map<ComplicationTypeRectF>
)

Public constructors

ComplicationSlotBounds

ComplicationSlotBounds(
    perComplicationTypeBounds: Map<ComplicationTypeRectF>
)

ComplicationSlotBounds

Added in 1.2.0
ComplicationSlotBounds(bounds: RectF, margins: RectF = RectF())

Constructs a ComplicationSlotBounds where all complication types have the same screen space unit-square bounds and margins.

ComplicationSlotBounds

ComplicationSlotBounds(
    perComplicationTypeBounds: Map<ComplicationTypeRectF>,
    perComplicationTypeMargins: Map<ComplicationTypeRectF>
)
Parameters
perComplicationTypeBounds: Map<ComplicationTypeRectF>

Per ComplicationType fractional unit-square screen space complication bounds.

perComplicationTypeMargins: Map<ComplicationTypeRectF>

Per ComplicationType fractional unit-square screen space complication margins for tap detection (doesn't affect rendering).