Search code examples
androidwear-oswatch-face-apiandroid-wear-2.0watchface

Android Wear watchface StatusBarGravity Bottom not respected


I'm making a watchface for Android Wear. I would like to position the status bar at the bottom instead of at the top.

The documentation states to use the setStatusBarGravity()-method of WatchFaceStyle.Builder: https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceStyle.Builder.html#setStatusBarGravity(int)

However, this does not seem to work as intended. Whenever I use Gravity.BOTTOM, the icons are centered vertically inside the watchface instead of positioned at the bottom.

This is the code I use:

setWatchFaceStyle(new WatchFaceStyle.Builder(Watchface.this)
                .setShowUnreadCountIndicator(true)
                .setStatusBarGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM)
                .setAcceptsTapEvents(true)
                .build());

Which results in this (notice the charging indicator in the middle)

img

What am I doing wrong? I have googled and SO'd, but couldn't find any relevant information.


Solution

  • What you're seeing, I'm afraid, is the Gravity.BOTTOM position. The placement of status bar icons is very generic, and the bottom alignment is just slightly below the actual vertical center, whereas Gravity.CENTER_VERTICAL is roughly one third of the screen.

    Here's a breakdown of the placement of the icons for the three gravity values:

    Gravity values for Wear OS

    Bear in mind that circular screens do not respect the horizontal gravity value.

    I know this is frustrating, but this is the way it is, I'm afraid. I'd suggest filing an issue at b.android.com to have this behavior changed.