从Android的BottomSheet片段的导航栏中删除空白/边距

问题描述 投票:0回答:1

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

enter image description here

android bottom-sheet
1个回答
0
投票

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

我通过将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


© www.soinside.com 2019 - 2024. All rights reserved.