Reputation: 2039
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)
What am I doing wrong? I have googled and SO'd, but couldn't find any relevant information.
Upvotes: 4
Views: 252
Reputation: 38252
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:
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.
Upvotes: 2
Reputation: 8092
Make sure that there are no spaces between the vertical bar separator and the Gravity constants because that will be perceived by the compiler as multiple parameters rather than one single “unified” Gravity concatenation parameter.
See "Building Your Watch Face: Using .setWatchFaceStyle()" in this documentation for more information.
Upvotes: -2