我正在使用WearableDrawerLayout
, 并在带有下巴的模拟器上进行测试。我试图让一个元素垂直居中。相反,我看到的是元素位于“屏幕减去下巴”区域的中心 - 即它向屏幕顶部移动了一点。
我所看到的:
我应该看到的:
从我在(非公开?)来源中可以看出,WearableDrawerLayout
我认为这是由于这一点:
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
this.mSystemWindowInsetBottom = insets.getSystemWindowInsetBottom();
if(this.mSystemWindowInsetBottom != 0) {
MarginLayoutParams layoutParams = (MarginLayoutParams)this.getLayoutParams();
layoutParams.bottomMargin = this.mSystemWindowInsetBottom;
this.setLayoutParams(layoutParams);
}
return super.onApplyWindowInsets(insets);
}
我该怎么做才能没有这个问题?
编辑:这是演示该问题的另一个布局示例:
如您所见,下巴不包括在可用区域中,这意味着BoxInsetLayout
它的高度小于应有的高度。结果,它的子按钮太“高”了——它们不是底部对齐的。
这是我的编辑(对我的 Gimp 技能感到抱歉),它显示了圆形显示,以及BoxInsetLayout
和 按钮的位置。