Skip to content

Most visited

Recently visited

navigation

Using the Wear UI Library

Android support libraries enable consistent, optimized user interfaces across apps. The Android Support Library includes the Wear UI Library, which contains many of the preferred UI components for your Wear apps.

The Wear UI Library includes (but is not limited to) the following classes. Some of the classes have similar names to, and offer several benefits over, the related deprecated classes in the Wearable Support Library:

Also see Action and Navigation Drawers in the Wear UI Library.

Add a Dependency on the Android Support Library

To use the Wear UI Library, add the following dependency in your Wear module's build.gradle file:

dependencies {
    ...
    compile 'com.android.support:wear:27.0.0'
}

If necessary, include a dependency on the Wearable Support Library (see Creating or Updating a Project). Also see Adding Support Libraries.

Import Classes from the Wear UI Library Package

When you use a class from the Wear UI Library, import that class from the android.support.wear.widget package. See the Example of Using a Library Class.

Use the Right Element Names in Layout Files

In layout files, use fully qualified names that correspond to the Wear UI Library (rather than to the Wearable Support Library).

For example, to use the SwipeDismissFrameLayout class from the Wear UI Library, you could specify the following in a layout file:

<android.support.wear.widget.SwipeDismissFrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/swipe_dismiss_root" >
 
    <TextView
        android:id="@+id/test_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:text="Swipe the screen to dismiss me." />
</android.support.wear.widget.SwipeDismissFrameLayout>

Example of Using a Library Class

The classes in the Wear UI Library have functionality that is the same or similar to that in the Wearable Support Library. Some class, method, and attribute names are updated to improve consistency with the Android Support Library.

For example, an activity that uses the WearableRecyclerView class from the Wearable Support Library could include the following code:

import android.support.wearable.view.WearableRecyclerView;
...
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.wearable_recycler_view_basic);
    WearableRecyclerView wrv = findViewById(R.id.wrv);
    wrv.setLayoutManager(new ChildLayoutManager());
    wrv.setAdapter(new TestAdapter());
}

Similarly, an activity that uses the WearableRecyclerView class from the Wear UI Library could include the following code. Differences from the above code are in bold:

import android.support.wear.widget.WearableRecyclerView;
...
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.wearable_recycler_view_basic);
    WearableRecyclerView wrv = findViewById(R.id.wrv);
    wrv.setLayoutManager(new WearableLinearLayoutManager(this));
    wrv.setAdapter(new TestAdapter());
}

Action and Navigation Drawers in the Wear UI Library

The Wear UI Library has components for action and navigation drawers.

For additional information, see Wear Navigation and Actions.

Replacements for Deprecated Classes

The table below contains replacements, in the Wear UI Library and elsewhere, for deprecated classes in the Wearable Support Library.

Deprecated class Replacement information
ActionChooserView AlertDialog
ActionLabel Use WearableActionDrawerView for navigation and ConfirmationOverlay for confirmation actions.
ActionPage Use WearableActionDrawerView for navigation and ConfirmationOverlay for confirmation actions.
BoxInsetLayout BoxInsetLayout
BoxInsetLayout.LayoutParams BoxInsetLayout.LayoutParams
CardFragment Use SnapHelper and a RecyclerView.
CardFrame Use SnapHelper and a RecyclerView.
CardScrollView Use SnapHelper and a RecyclerView.
CircledImageView RoundedDrawable
CircularButton See Material design library components.
CrossfadeDrawable AnimationSet
CurvedChildLayoutManager WearableLinearLayoutManager
DefaultOffsettingHelper WearableLinearLayoutManager
DelayedConfirmationView CircularProgressLayout
DismissOverlayView Not applicable; long-pressing to dismiss an app is no longer suggested for immersive activities.
DotsPageIndicator Not applicable; horizontal scrolling is no longer encouraged for apps.
FragmentGridPagerAdapter Use PageSnapHelper and a RecyclerView.
GridPagerAdapter Use SnapHelper and a RecyclerView.
GridViewPager Use SnapHelper and a RecyclerView.
GridViewPager.LayoutParams Not applicable; bi-directional spatial models are no longer encouraged for apps. If you are implementing a vertical paging pattern, consider using the SnapHelper and a RecyclerView.
ProgressSpinner ProgressBar
SwipeDismissFrameLayout SwipeDismissFrameLayout
SwipeDismissFrameLayout.Callback SwipeDismissFrameLayout.Callback
WatchViewStub See Providing Resources.
WearableFrameLayout See Providing Resources.
WearableFrameLayout.LayoutParams See Providing Resources.
WearableListView WearableRecyclerView
WearableListView.Adapter For centering and snapping list items, consider using the WearableRecyclerView, supported by a SnapHelper or a LinearSnapHelper. For scaling and otherwise modifying the list items based on their location on the screen, consider using a WearableLinearLayoutManager or a CurvingLayoutCallback.
WearableListView.GenericAdapter For centering and snapping list items, consider using the WearableRecyclerView, supported by a SnapHelper or a LinearSnapHelper. For scaling and otherwise modifying the list items based on their location on the screen, consider using a WearableLinearLayoutManager or a CurvingLayoutCallback.
WearableListView.ViewHolder For centering and snapping list items, consider using the WearableRecyclerView, supported by a SnapHelper or a LinearSnapHelper. For scaling and otherwise modifying the list items based on their location on the screen, consider using a WearableLinearLayoutManager or a CurvingLayoutCallback.
WearableRecyclerView WearableRecyclerView
WearableRecyclerView.ChildLayoutManager WearableLinearLayoutManager
WearableRecyclerView.OffsettingHelper WearableLinearLayoutManager.LayoutCallback
WearableActionDrawer WearableActionDrawerView
WearableDrawerLayout WearableDrawerLayout
WearableDrawerLayout.DrawerStateCallback WearableDrawerLayout.DrawerStateCallback
WearableDrawerView WearableDrawerView
WearableNavigationDrawer WearableNavigationDrawerView
WearableNavigationDrawer.WearableNavigationDrawerAdapter WearableNavigationDrawerView.WearableNavigationDrawerAdapter
This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)