The Watch Face Format is required for watch faces to be installed on devices with Wear OS 5 or later pre-installed and for all new watch faces published on Google Play.
Starting in January 2026, the Watch Face Format will be required for watch faces to be installed on all Wear OS devices.
Learn more about the user-facing changes in this Help Center article.
Disegna un quadrante
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Dopo aver configurato il progetto e aggiunto una classe che implementa il servizio di quadrante, puoi iniziare a scrivere il codice per inizializzare e disegnare il quadrante personalizzato.
Ogni quadrante crea una sottoclasse personalizzata di un renderer che implementa
tutto il necessario per disegnare il quadrante.
Il renderer combina
UserStyle
, le
informazioni sulle complicazioni di
ComplicationSlotsManager
,
l'ora corrente e altre informazioni sullo stato per
renderizzare il quadrante, come mostrato nell'esempio seguente:
class CustomCanvasRenderer(
private val context: Context,
surfaceHolder: SurfaceHolder,
watchState: WatchState,
private val complicationSlotsManager: ComplicationSlotsManager,
currentUserStyleRepository: CurrentUserStyleRepository,
canvasType: Int
) : Renderer.CanvasRenderer(
surfaceHolder = surfaceHolder,
currentUserStyleRepository = currentUserStyleRepository,
watchState = watchState,
canvasType = canvasType,
interactiveDrawModeUpdateDelayMillis = 16L
) {
override fun render(canvas: Canvas, bounds: Rect, zonedDateTime: ZonedDateTime) {
// Draw into the canvas
}
override fun renderHighlightLayer(canvas: Canvas, bounds: Rect, zonedDateTime: ZonedDateTime) {
// Draw into the canvas
}
}
I campioni di contenuti e codice in questa pagina sono soggetti alle licenze descritte nella Licenza per i contenuti. Java e OpenJDK sono marchi o marchi registrati di Oracle e/o delle sue società consociate.
Ultimo aggiornamento 2025-08-27 UTC.
[null,null,["Ultimo aggiornamento 2025-08-27 UTC."],[],[],null,["After you configure your project and add a class that implements the\nwatch face service, you can start writing code to initialize and draw your\ncustom watch face.\n\nEvery watch face creates a custom subclass of a renderer that implements\neverything needed to draw the watch face.\n\nThe renderer combines the\n[`UserStyle`](/reference/androidx/wear/watchface/style/UserStyle), the\ncomplication information from\n[`ComplicationSlotsManager`](/reference/androidx/wear/watchface/ComplicationSlotsManager),\nthe current time, and other state information to\nrender the watch face, as shown in the following example: \n\n class CustomCanvasRenderer(\n private val context: Context,\n surfaceHolder: SurfaceHolder,\n watchState: WatchState,\n private val complicationSlotsManager: ComplicationSlotsManager,\n currentUserStyleRepository: CurrentUserStyleRepository,\n canvasType: Int\n ) : Renderer.CanvasRenderer(\n surfaceHolder = surfaceHolder,\n currentUserStyleRepository = currentUserStyleRepository,\n watchState = watchState,\n canvasType = canvasType,\n interactiveDrawModeUpdateDelayMillis = 16L\n ) {\n override fun render(canvas: Canvas, bounds: Rect, zonedDateTime: ZonedDateTime) {\n // Draw into the canvas\n }\n\n override fun renderHighlightLayer(canvas: Canvas, bounds: Rect, zonedDateTime: ZonedDateTime) {\n // Draw into the canvas\n }\n }"]]