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 by Google 谷歌允许表盘在表盘上的指定位置接受单次点按手势,但前提是没有其他界面元素会响应该手势。
如需实现互动式表盘,请先构造表盘样式,然后实现本指南中所述的手势处理。
处理点按事件
系统只会为表盘提供点按事件,即用户将手指放在屏幕上然后抬起的事件。如果用户在手指放在触摸屏上的同时执行任何其他类型的手势,表盘就会收到取消事件,因为所有其他手势都被系统预留,用于其他功能。
如需处理点按手势,请使用 setTapListener()
添加一个 TapListener
。每当用户点按表盘时,系统都会调用监听器。
表盘会收到以下类型的触摸事件:
系统会根据 android.view.ViewConfiguration.getScaledTouchSlop
返回的值,验证 TapType.DOWN
事件和后续的 TapType.UP
事件是否为一次点按。
请勿在表盘收到 TapType.CANCEL
事件时触发操作,因为系统已在处理该手势。
如需了解详情,请参阅 onTapEvent
。
表盘示例应用演示了配置表盘的最佳实践。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[],[],null,["# Handle taps in watch faces\n\nA user can interact with your watch face in many ways.\nFor example, a user might tap the watch face to learn what song is currently playing or\nto see the day's agenda. Wear OS by Google lets watch faces accept\nthe single-tap gesture at a given location on the watch face, as long as there's not another\nUI element that also responds to that gesture.\n\nTo implement an interactive watch face, first construct the\nwatch face style, and then implement gesture handling as described in this guide.\n\nHandle tap events\n-----------------\n\nThe watch face is only given tap events, which are events where the user puts a finger\ndown on the screen and then lifts it. If the user performs any other\ntype of gesture while their finger is on the touchscreen, the watch face receives a\ncancel event, as all other gestures are reserved by the system for other functions.\n\n\nTo handle tap gestures, use\n[`setTapListener()`](/reference/kotlin/androidx/wear/watchface/WatchFace#setTapListener(androidx.wear.watchface.WatchFace.TapListener)) to add a\n[`TapListener`](/reference/kotlin/androidx/wear/watchface/WatchFace.TapListener).\nThe listener is called whenever the user taps on the watch face.\n\nThe watch face receives the following types of touch events:\n\n- TapType.DOWN:\n when the user puts their finger down on the touchscreen\n\n- TapType.UP:\n when the user lifts the finger from the touchscreen\n\n- TapType.CANCEL:\n when the system detects that the user performs a gesture other than a tap\n\nA\n`TapType.DOWN` event and the successive `TapType.UP`\nevent are verified as a tap according to the value returned by\n[android.view.ViewConfiguration.getScaledTouchSlop](/reference/android/view/ViewConfiguration#getScaledTouchSlop()).\n\nDon't trigger an action when the watch face receives a `TapType.CANCEL`\nevent, because the system is already processing the gesture.\n\nFor more information, see [onTapEvent](https://developer.android.com/reference/androidx/wear/watchface/WatchFace.TapListener#onTapEvent(kotlin.Int,androidx.wear.watchface.TapEvent,androidx.wear.watchface.ComplicationSlot)).\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."]]