从Android中BottomSheet片段中的导航栏删除间隙/边距

时间:2020-04-16 12:49:10

标签: android bottom-sheet

我正在使用底部的片段显示弹出窗口。 我使用https://stackoverflow.com/a/51329005/5519745设置导航栏颜色。但是,在某些设备中,导航栏和底部工作表对话框之间存在间隙。

enter image description here

1 个答案:

答案 0 :(得分:1)

我使用了与您相同的堆栈溢出解决方案,在导航栏上设置了白色背景,并且遇到了相同的问题。

我通过将 setWhiteNavigationBar setLayerInsetTop metrics.heightPixels 字段更新为一个较小的负值来解决此问题,以使底部页面一点。

希望这会有所帮助。


原始

windowBackground.setLayerInsetTop(1, metrics.heightPixels);

Original with gap between bottomsheet and navbar


已修订

windowBackground.setLayerInsetTop(1, metrics.heightPixels - 2);

enter image description here


相关问题