Working with Screen Sizes
- PDF for offline use
Let us know how you feel about this
last updated: 2017-06
Android Wear devices can have either a rectangular or a round display, which can also be different sizes.
Identifying Screen Type
The Wear support library provides some controls that help you detect
and adapt to different screen shapes, such as
Be aware that some of the other support library controls (such as
GridViewPager) automatically detect screen shape themselves and
shouldn't be added as children of the controls described below.
See the WatchViewStub sample to see how to detect screen type and display a different layout for each type.
The main layout file contains a
android.support.wearable.view.WatchViewStub which references
different layouts for rectangular and round screens using the
<android.support.wearable.view.WatchViewStub xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/stub" app:rectLayout="@layout/rect_layout" app:roundLayout="@layout/round_layout" />
The solution contains different layouts for each style which will be selected at run-time:
Rather than build different layouts for each screen type, you can also create a single view that adapts to rectangular or round screens.
shows how to use the
BoxInsetLayout to use the same layout on both
rectangular and round screens.
Wear UI Designer
The Xamarin Android Designer supports both rectangular and round screens:
The design surface in rectangular style is shown here:
The design surface in round style is shown here:
The Google Emulator Manager contains device definitions for both screen types. You can create rectangular and round emulators to test your app.
The emulator will render like this for a rectangular screen:
It will render like this for a round screen: