System indicators do not respect Gravity.BOTTOM

2019-07-09 14:14发布

I have taken the demo analog watch face, and tried getting the system indicators to appear at the bottom, using setStatusBarGravity(Gravity.BOTTOM). It appears that this particular gravity isn't respected.

setWatchFaceStyle(new WatchFaceStyle.Builder(AnalogWatchFace.this)
        .setCardPeekMode(WatchFaceStyle.PEEK_MODE_SHORT)
        .setBackgroundVisibility(WatchFaceStyle.BACKGROUND_VISIBILITY_INTERRUPTIVE)
        .setShowSystemUiTime(false)
        .setStatusBarGravity(Gravity.BOTTOM)
        .setHotwordIndicatorGravity(Gravity.BOTTOM)
        .build());

By setting it to this value, the indicators (and the "Ok Google" hotword indicator) appear in the center of the screen. On circular devices, they appear completely centered, on square devices vertically centered on the left.

I'm aware of an issue on Android Wear that the indicators aren't updated between relaunches of the app, but I've tried switching watch faces and even reinstalling it altogether. I've also tried using setStatusBarGravity() combining with a horizontal alignment with a binary OR, but only the horizontal gravity is respected for square devices.

Any idea what the problem might be?

1条回答
SAY GOODBYE
2楼-- · 2019-07-09 14:40

It seems that Gravity.BOTTOM is a bit misleading; the vertical alignment is not at the bottom of the screen, but in the bottom-most of some preset positions.

The position of the indicators appears to be relative; above any possible peeking cards and above the hotword indicator, if it is also set to Gravity.BOTTOM.

I found that if I set setHotwordIndicatorGravity(Gravity.CENTER), the system indicators appear slightly lower than setting both indicators to Gravity.BOTTOM. It's not ideal, but it's the best I could get. This no longer appears to be the case in Wear OS.

I've calculated the positions against a 390px circular display as:

  • Gravity.TOP: 8.7%
  • Gravity.CENTER_VERTICAL: 39.0%
  • Gravity.BOTTOM: 57.4%

Gravity of status bar icons

查看更多
登录 后发表回答