A user can interact with your watch face in many ways. For example, a user might tap the watch face to learn what song is currently playing or to see the day's agenda. Wear OS by Google lets watch faces accept the single-tap gesture at a given location on the watch face, as long as there's not another UI element that also responds to that gesture.
To implement an interactive watch face, first construct the watch face style, and then implement gesture handling as described in this guide.
Handle tap events
The watch face is only given tap events, which are events where the user puts a finger down on the screen and then lifts it. If the user performs any other type of gesture while their finger is on the touchscreen, the watch face receives a cancel event, as all other gestures are reserved by the system for other functions.
To handle tap gestures, use
setTapListener()
to add a
TapListener
.
The listener is called whenever the user taps on the watch face.
The watch face receives the following types of touch events:
-
TapType.DOWN
: when the user puts their finger down on the touchscreen -
TapType.UP
: when the user lifts the finger from the touchscreen -
TapType.CANCEL
: when the system detects that the user performs a gesture other than a tap
A
TapType.DOWN
event and the successive TapType.UP
event are verified as a tap according to the value returned by
android.view.ViewConfiguration.getScaledTouchSlop
.
Don't trigger an action when the watch face receives a TapType.CANCEL
event, because the system is already processing the gesture.
For more information, see onTapEvent
.
Related resources
The
watch face sample app demonstrates the best practices for configuring a watch face.