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 应用受益于自动硬件加速图形渲染。不过,表盘通常使用画布实现,因此不会自动获得硬件加速。
为何要为表盘使用硬件加速画布?
在大多数情况下,当使用硬件加速画布时,表盘将以较高的帧速率渲染。在较高的帧速率下,动画和过渡效果会更流畅,让用户获得更出色的体验。
使用硬件加速画布时,您还可以访问有关表盘的更多界面性能数据。例如,当使用硬件加速画布时,您可以访问衡量界面性能中描述的详细帧信息。
我的表盘是否在使用硬件加速?
您可以使用开发者选项或 adb
来检查表盘是否正在使用硬件加速。
使用开发者选项进行检查
如需使用开发者选项来检查表盘是否正在使用硬件加速,请按以下步骤操作:
- 在 Wear OS 设备上,依次访问设置 > 开发者选项。
启用调试 GPU 性能剖析。
此选项会在可见 surface 之上绘制一个叠加层(每个 surface 上一个叠加层),以显示该 surface 在 GPU 渲染的每个阶段所花费的时间。
在设备上,返回到您的表盘。
如果您的表盘使用硬件加速画布,您将看到一个新条,对于表盘的每个渲染帧,您将看到表盘的每个渲染帧对应的新柱从右向左移动。
使用 adb 检查
如需使用 adb
检查表盘是否正在使用硬件加速,请按以下步骤操作:
- 在 Wear OS 设备上,将表盘更改为要测试的表盘。
- 让表盘在互动模式下运行几秒钟。
运行以下 adb
命令以检查表盘是否正在使用硬件加速:
adb shell dumpsys gfxinfo [package-name]
运行该命令后,您会获得类似于以下示例的输出:
Applications Graphics Acceleration Info:
Uptime: 2239933 Realtime: 13568751
** Graphics info for pid 1100 [package-name] **
Stats since: 59875589194ns
Total frames rendered: 1213
Janky frames: 0 (0.00%)
50th percentile: 7ms
90th percentile: 18ms
95th percentile: 25ms
99th percentile: 150ms
Number Missed Vsync: 0
Number High input latency: 0
Number Slow UI thread: 0
Number Slow bitmap uploads: 0
Number Slow issue draw commands: 0
Number Frame deadline missed: 0
...
在此示例输出中,请注意显示 Total frames rendered
的代码行。通常,如果输出中的渲染帧总数大于 0,则表示表盘使用了加速画布。否则,输入中的渲染帧总数和其他帧数据通常为 0。
不过,由于 gfxinfo
是应用完整软件包的输出,因此您可能会看到除硬件加速画布以外的其他某些帧时间信息,例如应用为配置屏幕使用的 Activity
。如需区分这两者,请确保表盘是唯一可见的 surface,然后重新运行 adb shell dumpsys gfxinfo
命令以检查 Total frames rendered
的值是否会增加。
最佳实践
请遵循以下最佳实践确保为用户提供最佳体验。
尽可能延长电池续航时间
如果您的表盘有长时间运行的动画,则使用硬件加速会大幅缩短设备的电池续航时间。如果表盘在每一帧中都尝试进行绘制,则此问题会更严重。为避免对用户造成负面影响,请勿在表盘中使用长时间运行的动画。本指南并非专门介绍使用硬件加速,但使用硬件加速会增加能够绘制的帧数,因此遵循最佳实践尤为重要。如需了解详情,请参阅动画最佳实践。
使用受支持的绘图操作
使用硬件加速时不支持某些绘制操作。如需了解受支持的绘制操作,请参阅硬件加速。如果某个小代码路径使用了不受支持的操作,您可以创建一个基于位图的画布,然后使用 canvas.drawBitmap()
将该位图绘制到表盘的画布中。
在使用硬件加速时保持兼容性
硬件加速适用于搭载 Android 9(API 级别 28)或更高版本的 Wear OS 设备。如果您希望避免在硬件加速不可用的旧款设备上执行特定绘制操作,或者希望在硬件加速画布上执行不受支持的绘制操作,您可以检查 Canvas.isHardwareAccelerated()
,然后提供替代功能。
为您推荐
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Improve your watch face performance with hardware acceleration\n\nWear OS apps that use standard views benefit from automatic hardware-accelerated\ngraphics rendering. But watch faces are usually implemented using\ncanvases, so they don't automatically get hardware acceleration.\n\nWhy use a hardware-accelerated canvas for your watch face?\n----------------------------------------------------------\n\nIn most cases, your watch face renders at a higher frame rate when using a\nhardware-accelerated canvas. At higher frame rates, animations and transitions\nappear smoother to the eye, providing a better user experience.\n\nWhen you use a hardware-accelerated canvas, you can also access more UI\nperformance data about your watch face. For example, you can only access the\ndetailed frame information described in [Measure UI\nperformance](/topic/performance/overview)\nwhen you are using a hardware-accelerated canvas.\n\nIs my watch face using hardware acceleration?\n---------------------------------------------\n\nYou can check whether your watch face is using hardware acceleration\nusing either the developer options or `adb`.\n\n### Check using developer options\n\nTo use developer options to check whether your watch face is using hardware acceleration,\nfollow these steps:\n\n1. On a Wear OS device, navigate to **Settings** \\\u003e **Developer options**.\n2. Enable **Debug GPU profiling**.\n\n This option draws an overlay on top of visible surfaces, one on each surface,\n to show the amount of time spent in each stage of GPU rendering for that\n surface.\n3. On the device, navigate back to your watch face.\n\n4. If your watch face uses a hardware-accelerated canvas, you see a new bar\n that moves from right to left for each rendered frame of your watch face.\n\n### Check using adb\n\nTo use `adb` to check whether your watch face is using hardware acceleration,\nfollow these steps:\n\n1. On a Wear OS device, change the watch face to your watch face that you want to test.\n2. Let the watch face run for a few seconds in interactive mode.\n3. Run the following `adb` command to check whether your watch face is using\n hardware acceleration:\n\n `adb shell dumpsys gfxinfo `\u003cvar translate=\"no\"\u003e[package-name]\u003c/var\u003e\n\nAfter running the command, you get output similar to the following\nexample: \n\n```\nApplications Graphics Acceleration Info:\nUptime: 2239933 Realtime: 13568751\n\n** Graphics info for pid 1100 [package-name] **\n\nStats since: 59875589194ns\nTotal frames rendered: 1213\nJanky frames: 0 (0.00%)\n50th percentile: 7ms\n90th percentile: 18ms\n95th percentile: 25ms\n99th percentile: 150ms\nNumber Missed Vsync: 0\nNumber High input latency: 0\nNumber Slow UI thread: 0\nNumber Slow bitmap uploads: 0\nNumber Slow issue draw commands: 0\nNumber Frame deadline missed: 0\n\n...\n```\n\nIn this sample output, notice the line reading `Total frames rendered`.\nGenerally, if your output shows total frames rendered greater than 0, then your\nwatch face uses an accelerated canvas. Otherwise the total frames rendered\nand other frame data in the report is normally 0.\n\nHowever, because the `gfxinfo` is output for your app's full package, you might\nsee some frame time information from something other than a hardware-accelerated\ncanvas, such as an `Activity` that your app uses for a configuration screen. To\ntell the difference, make sure that your watch face is the only surface that is\nvisible and then rerun the `adb shell dumpsys gfxinfo` command to check whether\nthe value for `Total frames rendered` increases.\n\nBest practices\n--------------\n\nFollow these best practices to ensure the best possible experience for your\nusers.\n\n### Maximize battery life\n\nIf your watch face has long-running animations, using hardware acceleration can\ngreatly lower the battery life of a device. This problem can get worse if\nyour watch face tries to draw in every frame. To avoid negatively impacting your\nusers, don't use long-running animations in your watch face. This\nguideline is not specific to using hardware acceleration, but because using\nhardware acceleration increases the number of frames you're able to draw, it is\neven more important to follow. For more information, see [Best practices for\nanimations](/training/wearables/watch-faces/performance#Animations).\n\n### Use supported drawing operations\n\nSome drawing operations are are not supported when using hardware acceleration.\nFor information on what is supported, see [Hardware\nacceleration](/topic/performance/hardware-accel#drawing-support).\nIf you have a small code path that uses an unsupported operation, you can create\na bitmap-backed canvas and then draw that bitmap into the watch face's canvas\nusing\n[`canvas.drawBitmap()`](/reference/android/graphics/Canvas#drawBitmap(android.graphics.Bitmap,%20android.graphics.Rect,%20android.graphics.RectF,%20android.graphics.Paint)).\n\n### Maintain compatibility when using hardware acceleration\n\nHardware acceleration is available on Wear OS devices that run Android 9 (API\nlevel 28) or higher. If you want to avoid a specific draw operation on older\ndevices, where hardware acceleration is not available, or an unsupported draw\noperation on a hardware accelerated canvas, you can check [`Canvas.isHardwareAccelerated()`](/reference/android/graphics/Canvas#isHardwareAccelerated()),\nthen provide the alternative functionality.\n\nRecommended for you\n-------------------\n\n- Note: link text is displayed when JavaScript is off\n- [dumpsys](/tools/dumpsys)\n- [Slow rendering](/topic/performance/vitals/render)\n- [Device compatibility mode](/guide/practices/device-compatibility-mode)"]]