After designing individual screens for each user journey, you may have a few vertical or single screens.
Next, you have to decide how to design these screens to work together and how to implement the navigation.
As called out in the Overlay overview, it's important to keep your app's hierarchy shallow and linear.
To start, your app's launcher should open the most common user journey. Design each user journey with the most important content at the top. For vertical containers, use the bottom to link to other less-common user journeys and the settings.
When users enter one of your screens, they should be able to use the swipe-to-dismiss gesture to navigate down the back stack.
Implement the navigation
When implementing your navigation, you have three options.
Since vertical screens typically go one level deep, you can implement all your screens using activities and without using fragments.
Note: For your activity, you should inherit from a
you are not using fragments. The other activity types use mobile-specific UI elements you don't
need for Wear OS.
Activities and fragments
You can use fragments with activities in your Wear OS app. However, we don't recommend it as there isn't a clear advantage to using them to create a shallow and flat architecture. Some of the difficulties with using fragments are described in the following list:
- You must implement the swipe-to-dismiss yourself. Otherwise, when the user performs a swipe, they will exit the entire app.
If you are using
AmbientMode, you must customize it to work properly.
AmbientModeis set on the activity, so you have to take that into account when implementing fragments.
To support swipe-to-dismiss,
Fragments require that you wrap a fragment-containing
view in the
class. See the
for more information. This provides users a consistent experience with your app.
Note: If you are using fragments with your activity, you should inherit from
other activity types use mobile specific UI elements you don't need for Wear OS.
Note: When using fragments within your activity, use
to support the
This will ensure that your previous fragment will render under the top fragment while it is being
Jetpack Navigation can work on Wear OS but has the same drawbacks as using fragments. It adds development work and because Wear OS app's hierarchy is generally shallow and linear, it doesn't offer as many advantages. As outlined earlier, an activity-only approach is best.
To fully leverage Jetpack Navigation, do the following:
Make sure every fragment uses a
SwipeDismissFrameLayoutas root and manually use the dismiss action to go back in the navigation graph.
Implement a custom
FragmentNavigatorthat renders fragments on top of each other.