【发布时间】:2017-02-09 16:14:48
【问题描述】:
我正在使用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 和按钮的位置。
【问题讨论】: