System indicators do not respect Gravity.BOTTOM

送分小仙女□ 提交于 2020-01-04 09:21:13

问题


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:


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%



来源:https://stackoverflow.com/questions/35003486/system-indicators-do-not-respect-gravity-bottom

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!