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.
优化表盘
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Wear OS 表盘会持续不断地运行,所以必须高效地使用电能。
请尽可能优化表盘的性能。本页面提供关于整体表盘优化的最佳实践,以及动画最佳实践和图片最佳实践。
基本优化
此部分包含提升表盘整体效率的最佳实践。
表盘颜色和亮度
在表盘中使用深色可以降低用户手表的功耗。以下是有关如何设置表盘背景以优化表盘电池使用情况的建议:
- 颜色:尽可能使用黑色背景。
- 亮度:如果无法使用黑色背景,请确保背景颜色的亮度在色相、饱和度、明度 (HSV) 或色相、饱和度、亮度 (HSB) 刻度上不超过 25%。例如,如果您使用
Color
类来设置通过 HSV 刻度定义的背景颜色,请使用 25 或更低的值设置(用于控制亮度)。
借助动态功能与手机进行交互
当表盘需要在手机上运行某项操作时,只能在表盘处于活动状态时执行相应代码。建议利用 CapabilityClient API 使手机上的应用确定对应的表盘是否处于活动状态。
监控耗电量
Wear OS 配套应用让开发者和用户能够查看穿戴式设备上不同进程消耗的电量。如需查看,请依次选择设置 > 手表电池。
注册加密感知表盘
Android 7.0 及更高版本支持文件级加密,并允许加密感知应用在用户(在启动时)提供解密密码之前运行。这可以将从启动动画到表盘的过渡时间缩短多达 30 秒。
若要使启动速度更快,请将 android:directBootAware="true"
添加到表盘清单中。
注意:请将此功能与不使用凭据加密存储空间的表盘结合使用。
动画最佳实践
此部分介绍的最佳实践有助于减少与动画相关的耗电量。
降低动画的帧速率
动画的计算开销通常很大,且十分耗电。大多数动画在帧速率为每秒 30 帧时看起来已经比较流畅,所以请避免以更高的帧速率运行动画。您可以改用动态帧速率。如需了解详情,请参阅示例画布表盘。
使 CPU 在各动画之间休眠
如需最大限度地延长电池续航时间,请谨慎使用动画。即使是闪烁的冒号,每次闪烁都会消耗电池电量。
动画和对表盘内容的细微更改都会唤醒 CPU。让 CPU 在动画之间休眠,例如在交互模式下使用每秒短时动画,然后使 CPU 休眠到下一秒。使 CPU 经常休眠,即使时间很短,也可以大幅度地降低耗电量。
图片最佳实践
此部分介绍的最佳实践有助于减少与图片相关的耗电量。
缩减位图资源的大小
许多表盘都包含背景图片及其他图形资源,这些资源会在背景图片上转换和叠加,例如时钟指针和其他元素会随着时间的流逝而移动。图形资源越大,转换其所需的计算开销就越大。如绘制表盘中所述,在系统每次重新绘制表盘时,这些图形元素通常会在 Render.CanvasRenderer.render()
方法内旋转(有时会缩放)。
图 1. 剪裁时钟指针以移除多余的像素。
缩减位图资源的大小可改善动画性能并节省电量。请按照以下提示改善表盘的性能:
- 不要使用大于实际需求的图形元素。
- 移除边缘多余的透明像素。
例如,通过移除多余的透明像素,图 1 左侧的时钟指针图片的大小可以缩减 97%,如图 9 的右侧所示。
组合位图资源
如果您的某些位图经常一起绘制,不妨考虑将它们组合到单一图形资源中。您通常可以在交互模式下将背景图片与刻度线组合到一起,以避免系统每次重新绘制表盘时都绘制两个全屏位图。
绘制缩放后的位图时停用抗锯齿
当您使用
Canvas.drawBitmap()
方法在 Canvas
对象上绘制缩放后的位图时,您可以提供 Paint
实例来配置多个选项。若要提升性能,请使用 setAntiAlias()
方法停用抗锯齿,因为此选项对位图没有任何影响。
图 2. 停用(左侧)和启用(右侧)位图过滤的示例。
使用位图过滤
对于在其他元素之上绘制的位图资源,请使用 setFilterBitmap()
方法在相同的 Paint
实例上启用位图过滤。图 2 显示了应用和未应用位图过滤的时钟指针的放大视图。
注意:当氛围模式处于活动状态时,请停用位图过滤。在低位氛围模式下,系统无法在图像中为位图过滤可靠地渲染颜色以成功处理。
将开销大的操作移出绘制方法
每次重新绘制表盘时,系统都会调用 Render.CanvasRenderer.render()
方法。为了改善性能,请仅在此方法中包含更新表盘所必需的操作。
请尽可能避免在 Render.CanvasRenderer.render()
方法中执行以下操作:
- 加载图片和其他资源
- 调整图像大小
- 分配对象
- 执行其结果在各个帧之间不会改变的计算任务
如需分析表盘的性能,请使用 CPU 性能分析器。特别是,请确保 Render.CanvasRenderer.render()
实现的执行时间很短暂,且在不同的调用过程中保持一致。如需了解详情,请参阅使用 CPU 性能分析器检查 CPU 活动。
表盘示例应用演示了配置表盘的最佳实践。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[[["易于理解","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"]],["最后更新时间 (UTC):2025-07-26。"],[],[],null,["# Optimize watch faces\n\nA Wear OS watch face runs continuously, so it must use power efficiently.\n\nOptimize the performance of the watch face as much as possible.\nThis page provides best practices for overall watch face optimizations as well as\nbest practices targeted to animations and images.\n\nBasic optimization\n------------------\n\nThis section contains best practices for improving the overall efficiency of your watch face.\n\n### Watch face color and brightness\n\nUsing dark colors in your watch face draws less power from the user's watch.\nThe following are recommendations for setting the watch face background\nto optimize the watch face's battery use:\n\n- **Color:** whenever possible, use a black background.\n- **Brightness:** when a black background is not possible, keep the brightness of the background color at or below 25% on a hue, saturation, value (HSV) or hue, saturation, brightness (HSB) scale. For example, if you use the [`Color`](/reference/android/graphics/Color) class to set a background color defined with the HSV scale, use 25 or lower for the value setting, which controls brightness.\n\n### Use dynamic capabilities to interact with the phone\n\nWhen a watch face requires an operation to run on the phone, execute the code only\nwhen the watch face is active. The recommended method for letting the app on the phone learn that\nthe corresponding watch face is active is the\n[CapabilityClient API](https://developers.google.com/android/reference/com/google/android/gms/wearable/CapabilityClient).\n\n### Monitor power consumption\n\nThe [Wear OS companion app](https://play.google.com/store/apps/details?id=com.google.android.wearable.app&hl=en) lets developers and users see how much battery\nis consumed by different processes\non the wearable device. To see this, navigate to **Settings** \\\u003e **Watch\nbattery**.\n\n### Register encryption-aware watch faces\n\nAndroid 7.0 and higher include support for file-based encryption and let\n[encryption-aware](/training/articles/direct-boot) applications\nrun before the user has provided the decryption passcode at bootup. This can reduce the\nduration of transitioning from boot animation to the watch face by up to 30 seconds.\n\nTo enable faster bootup, add `android:directBootAware=\"true\"` to the watch face\nmanifest.\n\n**Note:** Use this feature with watch\nfaces that don't use credential-encrypted storage.\n\nBest practices for animations\n-----------------------------\n\nThe best practices in this section help reduce the power consumption associated with\nanimations.\n\n### Reduce the frame rate of animations\n\nAnimations are often computationally expensive and consume a significant amount of power. Most\nanimations look fluid at 30 frames per second, so avoid running your animations\nat a higher frame rate. Instead, you can use dynamic frame rates. For more information, see the\n[Example Canvas Watch Face](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:wear/watchface/watchface/samples/src/main/java/androidx/wear/watchface/samples/ExampleCanvasDigitalWatchFaceService.kt;l=893?q=this.interactiveDrawModeUpdateDelayMillis%20%3D).\n\n### Let the CPU sleep between animations\n\nTo maximize battery life, use animations sparingly. Even a blinking colon uses battery\npower with every blink.\n\nAnimations and small changes to the contents of the watch face wake up the CPU.\nLet the CPU sleep between animations by, for example, using short bursts of\nanimation every second in interactive mode and then letting the CPU sleep until the next second.\nLetting the CPU sleep often, even briefly, can significantly reduce power consumption.\n\nBest practices for images\n-------------------------\n\nThe best practices in this section help reduce the power consumption associated with\nimages.\n\nReduce the size of your bitmap assets\n-------------------------------------\n\nMany watch faces consist of a background image plus other graphic assets that are transformed\nand overlaid onto the background image, such as clock hands and other elements\nthat move over time. The larger these graphic assets are, the more computationally expensive it is\nto transform them. Typically, these graphic elements are rotated, and sometimes scaled, inside the\n[`Render.CanvasRenderer.render()`](/reference/kotlin/androidx/wear/watchface/Renderer.CanvasRenderer#render(android.graphics.Canvas,android.graphics.Rect,java.time.ZonedDateTime)) method every time the system redraws the watch face,\nas described in [Draw a watch face](/training/wearables/watch-faces/drawing#Drawing). \n\n\n**Figure 1.** Crop clock hands to remove extra pixels.\n\nReducing the size of your bitmap assets improves\nthe performance of your animations and saves power.\nFollow these tips to improve the performance of your watch face:\n\n- Don't use graphic elements that are larger than you need.\n- Remove extra transparent pixels around the edges.\n\nFor example, the size of the clock hand image on the left in figure 1 can be reduced\nby 97% by removing the extra transparent pixels, as shown on the right side of the figure.\n\nCombine bitmap assets\n---------------------\n\nIf you have bitmaps that are often drawn together, consider combining them into a single\ngraphic asset. For example, you can often combine the background image in interactive mode with the tick\nmarks to avoid drawing two full-screen bitmaps every time the system redraws the watch face.\n\nDisable anti-aliasing when drawing scaled bitmaps\n-------------------------------------------------\n\nWhen you draw a scaled bitmap on the\n[Canvas](/reference/android/graphics/Canvas) object using the\n[Canvas.drawBitmap()](/reference/android/graphics/Canvas#drawBitmap(android.graphics.Bitmap, float, float, android.graphics.Paint)) method, you can provide a\n[Paint](/reference/android/graphics/Paint) instance to configure\nseveral options. To improve performance, disable anti-aliasing using the\n[setAntiAlias()](/reference/android/graphics/Paint#setAntiAlias(boolean))\nmethod, since this option doesn't have any effect on bitmaps. \n\n**Figure 2.** Example of bitmap filtering disabled (left) and\nenabled (right).\n\nUse bitmap filtering\n--------------------\n\nFor bitmap assets that you draw on top of other elements, enable bitmap filtering on the same\n`Paint` instance using the\n[setFilterBitmap()](/reference/android/graphics/Paint#setFilterBitmap(boolean))\nmethod. Figure 2 shows a magnified view of a clock hand with\nand without bitmap filtering.\n\n**Note:** When ambient mode is\nactive, disable bitmap filtering. In low-bit ambient mode, the system does not reliably\nrender the colors in the image for bitmap filtering to process successfully.\n\nMove expensive operations outside the drawing method\n----------------------------------------------------\n\nThe system calls the `Render.CanvasRenderer.render()`\nmethod every time it redraws your watch face. To improve performance, only include\noperations inside this method that are strictly required to update the watch face.\n\n\nWhen possible, avoid performing the following operations inside the\n`Render.CanvasRenderer.render()` method:\n\n- Loading images and other resources\n- Resizing images\n- Allocating objects\n- Computations whose results don't change between frames\n\nTo analyze the performance of your watch face, use the CPU Profiler. In particular,\nmake sure that the execution time for your `Render.CanvasRenderer.render()`\nimplementation is short and\nconsistent across invocations. For more information, see\n[Inspect CPU activity with CPU Profiler](/studio/profile/cpu-profiler).\n\nRelated resources\n-----------------\n\n\nThe\n[watch face sample app](https://github.com/android/wear-os-samples) demonstrates the best practices for configuring a watch face."]]