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.
Нарисуйте циферблат
Оптимизируйте свои подборки
Сохраняйте и классифицируйте контент в соответствии со своими настройками.
После настройки проекта и добавления класса, реализующего службу циферблата, вы можете приступить к написанию кода для инициализации и отрисовки вашего собственного циферблата.
Каждый циферблат создает собственный подкласс рендерера, который реализует все необходимое для отрисовки циферблата.
Средство визуализации объединяет UserStyle
, информацию о сложностях из ComplicationSlotsManager
, текущее время и другую информацию о состоянии для визуализации циферблата часов, как показано в следующем примере:
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
}
}
Контент и образцы кода на этой странице предоставлены по лицензиям. Java и OpenJDK – это зарегистрированные товарные знаки корпорации Oracle и ее аффилированных лиц.
Последнее обновление: 2025-08-27 UTC.
[[["Прост для понимания","easyToUnderstand","thumb-up"],["Помог мне решить мою проблему","solvedMyProblem","thumb-up"],["Другое","otherUp","thumb-up"]],[["Отсутствует нужная мне информация","missingTheInformationINeed","thumb-down"],["Слишком сложен/слишком много шагов","tooComplicatedTooManySteps","thumb-down"],["Устарел","outOfDate","thumb-down"],["Проблема с переводом текста","translationIssue","thumb-down"],["Проблемы образцов/кода","samplesCodeIssue","thumb-down"],["Другое","otherDown","thumb-down"]],["Последнее обновление: 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 }"]]