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.

public final 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(
    @NonNull Map<@NonNull ComplicationType, @NonNull RectF> perComplicationTypeBounds
)

This method is deprecated. Use a constructor that specifies perComplicationTypeMargins

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

ComplicationSlotBounds(
    @NonNull Map<@NonNull ComplicationType, @NonNull RectF> perComplicationTypeBounds,
    @NonNull Map<@NonNull ComplicationType, @NonNull RectF> perComplicationTypeMargins
)

Public constructors

ComplicationSlotBounds

public ComplicationSlotBounds(
    @NonNull Map<@NonNull ComplicationType, @NonNull RectF> perComplicationTypeBounds
)

ComplicationSlotBounds

Added in 1.2.0
public ComplicationSlotBounds(@NonNull RectF bounds, @NonNull RectF margins)

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

ComplicationSlotBounds

public ComplicationSlotBounds(
    @NonNull Map<@NonNull ComplicationType, @NonNull RectF> perComplicationTypeBounds,
    @NonNull Map<@NonNull ComplicationType, @NonNull RectF> perComplicationTypeMargins
)
Parameters
@NonNull Map<@NonNull ComplicationType, @NonNull RectF> perComplicationTypeBounds

Per ComplicationType fractional unit-square screen space complication bounds.

@NonNull Map<@NonNull ComplicationType, @NonNull RectF> perComplicationTypeMargins

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