Now, with Wear OS 7, we're expanding this functionality with a new Gestures framework that allows OEMs to map gestures to primary actions and dismissals, and an API to bring gesture control to the developer community. 7 beta release of Compose for Wear OS , you can seamlessly integrate gesture control into your Wear Compose apps. 0-beta01 Designing for one-handed interaction The one-handed gestures framework is designed around two primary interaction patterns that allow users to take action without touching the screen: Primary action, which on Pixel Watch is mapped to a double-pinch gesture: this action should be mapped to the most important task in a given context.
Dismiss action, which on Pixel Watch is mapped to a wrist turn gesture: this action is mapped to system back by default and provides an intuitive way to close interruptive screens or get back to the watch face. It may be overridden for specific use cases, such as silencing an incoming phone call. These gestures are currently available on Pixel Watch 3 and newer, and the Wear OS gesture framework is available to all Wear OS device manufactures to adopt.
Check out our new design guidance for integrating one-handed gestures into your Wear app. Implementing gestures with Compose on Wear OS requires these steps: Define the gesture configuration. Start by using rememberOneHandedGestureConfiguration to define the nature of the interaction.
g. tracking a primary pinch or a dismiss wrist flick). Initialize the indicator state.
Depending on your UI component, initialize a specific state object, such as OneHandedGestureClickIndicatorState for buttons or OneHandedGestureScrollIndicatorState for scrollable lists. This state is used to coordinate visual feedback between the gesture detection modifier and the visual UI indicators, seamlessly managing visibility, timing, and animations. oneHandedGesture to your interactive component.
You'll pass in your configuration and state, and you’ll provide standard callbacks: onGestureAvailable to activate the visual hint when the system prepares the gesture, and onGesture to execute your action when the gesture happens. showIndicator() } }, onGesture = onPlayPauseButtonClicked, ), ) { // button content goes here // See "Guided discovery with gesture indicators" section of this post for recommendations on adding a gesture indicator. Primary can also be used to scroll when the content is the end goal of the user journey, or there is a gesture actionable button off screen that the user can scroll to.
Some examples include: Scrolling through a notification to view the content and/or initiate a reply (available in TransformingLazyColumn and ScalingLazyColumn ). scrollDown(scrollState) } ) ) { // list content goes here // See "Guided discovery with gesture indicators" section of this post for recommendations on adding a gesture indicator. } Guided discovery with gesture indicators To help users learn which gestures are available, gesture indicators work as hints to help discovery about which gestures are available on a screen.
These hints provide animated cues that inform users where they can perform a gesture. The framework manages the cadence and appearance of these hints, ensuring that they are helpful without being intrusive. System settings let users change the cadence to something less frequent if desired.
To integrate with hints, the API provides the following gesture indicator components: the OneHandedGestureClickIndicator for components like a Button the OneHandedGestureScrollIndicator component for scrolling the OneHandedGestureHorizontalPageIndicator for the HorizontalPager the OneHandedGestureVerticalPageIndicator for the VerticalPager The following example shows how to use the OneHandedGestureClickIndicator for a Button . See another example for using the OneHandedGestureScrollIndicator in our guidance . PlayArrow Icon(icon, contentDescription = "Play or Pause") } } Sample app showing gesture hint for media controls We are already seeing early adoption of these APIs from partners like Spotify, who are using one-handed gestures to make music control more seamless on the go.
oneHandedGesture into their Wear OS app, Spotify allows users to play or pause their music with the primary gesture action, which on Pixel Watch devices is the double-pinch gesture. This action triggers the same behavior as the physical play/pause button, and the user doesn’t need to touch the screen. 7 beta release of Compose for Wear OS.
Ensure your app is running on Wear OS 7, which provides the underlying platform support for gesture detection. Check out our new one-handed gestures developer guide to see how you can start building more convenient experiences for your users.
Android Developers Blog
android-developers.googleblog.com